First Chap C++ An Idex of C++
First Chap C++ An Idex of C++
By Sultan
History
• C is a programming Language which is developed during 1970
by Dennis Ritchie . In the case of this language the data was
not secured.
• C Language is not an object oriented language it is a oriented
language. Now what is Object Oriented Language it will be
discuss later.
• In C programming, a program can be divided into smaller
programs called functions. And it doesn't support Function
overloading.
• C++ is also called as C with classes or we can say C++ is a C
language with more features.
History
• C++ is a middle-level programming language developed by BJARNE
STROUSTRUP starting in 1979 at Bell Labs. originally named C with Classes
but later it was renamed C++ in 1983.
• C++ runs on a variety of platforms, such as Windows, Mac OS, and the various
versions of UNIX
The increment operator (++) adds 1 to its operand, and the decrement
operator (--)subtracts 1 from its operand.
x = x+1; is the same as x++
x = x-1; is the same as x--
Both the increment and decrement operators can either Prefix or Postfix.
There is an important difference in prefix and postfix forms which will be
discuss later
The if, if...else and nested if...else statement are used to make one-time
decisions in C++ Programming, use to execute some codes and ignore some
codes depending upon the test condition.
if Statement
The if statement checks
whether the test condition is
true or not. If the test
condition is true, it executes
the code/s inside the body of
if statement. But it the test The if keyword is followed by test condition inside parenthesis
( ). If the test condition is true, the codes inside curly bracket
condition is false, it skips is executed but if test condition is false, the codes inside curly
the code/s inside the body of bracket { } is skipped and control of program goes just below
if statement. the body of if as shown in figure above
Flow Chart of if Statement
Else if Statement
• This statement is executed when if
statements become fail. So the compiler
checks for the else if statement. Same if
the first else if statement become fail
again it will check for the third else if
statement, same action will be perform. If
none of the if and else if statement
become true then the last bock (else
block) will be execute.
Else if flow Chart
Nested if Statement
While (condition ){
Statements
}
Program
Flow Chart
For Loop
• A for loop is a repetition control structure
that allows you to efficiently write a loop
that needs to execute a specific number of
time.
• Syntax:
do{
Statements;
}while (condition)
Program
Switch Statement
Programming 2