You are on page 1of 15

Programming in C++

Strategies for learning C++


Focus on concepts and programming
techniques. (Dont get lost in language
features)
Learn C++ to become a better programmer
More effective at designing and
implementing.
Learn C++ gradually
Dont have to know every detail of C++ to
write a good C++ program.
Introduction
Alexander Graham Bell
C Language developed by Brian M Kernighan and
Dennis Ritchie at Bell Labs in early 1970s
Unix OS developed in C language
Inherited from two previously programming
languages BCPL and B.
BCPL Basic Combined Programming
Language) A programming language developed
by Martin Richards in Cambridge in 1967
C++ is a superset of C language, 1980
Introduction
C++ was written by Bjarne
Stroustrup at Bell Labs during 1983-
1985. Prior to 1983, Bjarne Stroustrup
added features to C and formed what
Bjarne Stroustrup he called "C with Classes". He had
combined the use of classes and
object-oriented features with the power
and efficiency of C. The term C++ was
first used in 1983.
C++ program Execution

Text Editor Compiler Linker

Run Program

Program Output

Source File
Object File
Program
An ordered list of events to take place or procedures to
be followed; a schedule
Computer Program
A collection of instructions that tell the computer to do
specific activity.
A program is generally known as "software
Application programs
System Software
Program
the terms software, application, program and instruction
are synonymous in the sense that they all tell the
computer to do some specific activity.

A program is written in a programming language, such


as C or C++

assemblers, compilers and interpreters.

The program contains machine instructions, buffers,


constants and counters.
Algorithm
A step-by-step problem-solving procedure, especially an
established, computational procedure for solving a
problem in a finite number of steps.

A set of ordered steps for solving a problem, such as a


mathematical formula or the instructions in a program.

algorithm and logic


Variable

In computer science and mathematics, a variable


(sometimes called a pronumeral) is a symbol
denoting a quantity or symbolic representation. In
mathematics, a variable often represents an
unknown quantity that has the potential to change;
in computer science, it represents a place where a
quantity can be stored. Variables are often
contrasted with constants, which are known and
unchanging.
Number

Memory
10

cout
cin
int number;

cin >> number;

cout << number;


Data
03091989 03/09/1989

600 Integer Number

7.821 Real Number


$ Character

Computer
Strings
Systems and
Programming
Variables are used for manipulating such type
of data
Variable declaration
Variable declaration

int x;
char ch;
float y;
int number;
string subject;
Boolean
Boolean literals
There are only two valid Boolean values: true and false.
These can be expressed in C++ as values of type bool
by using the Boolean literals true and false.

Example:
bool flag1, flag2;
flag1 = false;
flag2 = true;

false will give 0 value


true will give 1 value
Scope of variables
Fundamental Data Types

Name Description Size*


char Character 1byte
short int
Short Integer. 2bytes
(short)
int Integer. 4bytes
Boolean value. It can take one of two
bool 1byte
values: true or false.
float Floating point number. 4bytes
double Double precision floating point number. 8bytes

You might also like