SlideShare une entreprise Scribd logo
1  sur  42
Télécharger pour lire hors ligne
C++ 
Programming Language 
L03-CONTROL STRUCTURE 
Mohammad Shaker 
mohammadshaker.com 
@ZGTRShaker 
2010, 11, 12, 13, 14
Control Structure
Control Structure 
•If else 
•While 
•do while 
–Executed at least once whatever the condition is. 
•for 
•switch
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 4; 
if( x == 4 ) 
{ 
cout << "True "<< endl; 
} 
else 
{ 
cout << "False "<< endl; 
} 
} 
True 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 4; 
if( x = 4 ) 
{ 
cout << "True "<< endl; 
} 
else 
{ 
cout << "False "<< endl; 
} 
} 
True
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 4; 
if( x = 5 ) 
{ 
cout << "True "<< endl; 
} 
else 
{ 
cout << "False "<< endl; 
} 
} 
True 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 4; 
if( x!= 4 ) 
{ 
cout << "True "<< endl; 
} 
else 
{ 
cout << "False "<< endl; 
} 
} 
False
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 4; 
if( x == 4 ) 
cout << "True "<< endl; 
else 
cout << "False "<< endl; 
cout << "foo"<< endl; 
} 
True 
foo 
#include<iostream> 
usingnamespace::std; 
ints=0; 
voidmain(void) 
{ 
intx=0; 
if(x=0) 
{ 
cout<<"joo"<<endl; 
} 
cout<<"yoo"<<endl; 
system("pause"); 
} 
yoo 
Every other number other than 0 means true
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 5; 
while(x!= 10) 
{ 
x++; 
cout << x << endl; 
} 
} 
6 
7 
8 
9 
10 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 5; 
while(x!= 10) 
{ 
cout << x++ << endl; 
} 
} 
5 
6 
7 
8 
9
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 5; 
while(x!= 10) 
{ 
cout << ++x << endl; 
} 
} 
6 
7 
8 
9 
10 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 5; 
while(x!= 10) 
{ 
++x; 
cout << x << endl; 
} 
} 
6 
7 
8 
9 
10
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 5; 
while(x < 10) 
{ 
cout << x*x << endl; 
} 
} 
25 
25 
Indefinitely 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 5; 
while(x*x < 10) 
{ 
cout << x*x << endl; 
} 
}
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 5; 
while(cin) 
{ 
cin >> x; 
cout << x*x << endl; 
} 
} 
2 
4 
4 
16 
6 
36 
8 
64 
1 
1 
2 
4 
^Z 
4 
Press any key to continue 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 5; 
do 
{ 
cout << x << endl; 
x++; 
} while( x < 10 ); 
} 
5 
6 
7 
8 
9 
Press any key to continue
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 5; 
do 
{ 
cout << x << endl; 
x++; 
} while( x < 10 ) 
} 
Compiler error, missing “;” after the while(); 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 5; 
do 
{ 
cout << x << endl; 
} while( x < 4 ); 
} 
5 
do while execute at least one, eventhough the condition is not fulfilled.
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 5; 
do 
{ 
cout << "Enter the x:"<< endl; 
cin >> x; 
cout << "You have entered, x = "<< x 
<< endl; 
cout << "____________________________" 
<< endl; 
} while( x!= 0 ); 
} 
Enter the x: 
2 
You have entered, x = 2 
________________________________ 
Enter the x: 
3 
You have entered, x = 3 
________________________________ 
Enter the x: 
4 
You have entered, x = 4 
________________________________ 
Enter the x: 
23 
You have entered, x = 23 
________________________________ 
Enter the x: 
0 
You have entered, x = 0 
________________________________ 
Press any key to continue
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 0; 
intc = 5; 
do 
{ 
++c; 
cout << "beep!, number = "<< i << endl; 
i++; 
} while( ++c < 10 ); 
} 
beep!, number = 0 
beep!, number = 1 
beep!, number = 2 
Press any key to continue 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 0; 
intc = 5; 
do 
{ 
++c; 
cout << "beep!, number = "<< i << endl; 
i++; 
} while( c++ < 10 ); 
} 
beep!, number = 0 
beep!, number = 1 
beep!, number = 2 
Press any key to continue
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 0; 
intc = 5; 
do 
{ 
++c; 
cout << "beep!, number = "<< i << endl; 
i++; 
} while( ++c <= 10 ); 
} 
beep!, number = 0 
beep!, number = 1 
beep!, number = 2 
Press any key to continue
Code Cracking
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
for(inti = 0; i < 10; i++) 
{ 
cout<<"beep!, number = “<<i<<endl; 
} 
cout << "finished"<< endl; 
} 
beep!, number = 0 
beep!, number = 1 
beep!, number = 2 
beep!, number = 3 
beep!, number = 4 
beep!, number = 5 
beep!, number = 6 
beep!, number = 7 
beep!, number = 8 
beep!, number = 9 
finished 
Press any key to continue 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 5; 
for(inti = 0; i < 10; i++) 
{ 
cout << "beep!, number = "<< i 
<< endl; 
} 
cout << "finished"<< endl; 
} 
beep!, number = 0 
beep!, number = 1 
beep!, number = 2 
beep!, number = 3 
beep!, number = 4 
beep!, number = 5 
beep!, number = 6 
beep!, number = 7 
beep!, number = 8 
beep!, number = 9 
finished 
Press any key to continue
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 5; 
intc = 5; 
for(inti = 0; i < 10; i++) 
{ 
cout << "beep!, number = “ 
<< i << endl; 
i++; 
} 
cout << "finished"<< endl; 
} 
beep!, number = 0 
beep!, number = 2 
beep!, number = 4 
beep!, number = 6 
beep!, number = 8 
finished 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 66; 
intc = 5; 
for(inti = 0; i < 10; i++); 
{ 
cout << "beep!, number = "<< i << endl; 
i++; 
} 
cout << "finished"<< endl; 
} 
beep!, number = 66 
finished 
Press any key to continue 
Watch out for the semi colon “;” after the for statement Coz it close it
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 66; 
intc = 5; 
for(inti = 0; i < 10; ) 
{ 
cout << "beep!, number = "<< i << endl; 
i++; 
} 
cout << "finished"<< endl; 
} 
beep!, number = 0 
beep!, number = 1 
beep!, number = 2 
beep!, number = 3 
beep!, number = 4 
beep!, number = 5 
beep!, number = 6 
beep!, number = 7 
beep!, number = 8 
beep!, number = 9 
finished 
Press any key to continue 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 66; 
intc = 5; 
for(inti = 0; i < 10; ); 
{ 
cout << "beep!, number = "<< i << endl; 
i++; 
} 
cout << "finished"<< endl; 
} 
infinte loop, Nothing to print
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 66; 
intc = 5; 
for(inti = 0;; ) 
{ 
cout << "beep!, number = "<< i << endl; 
i++; 
} 
cout << "finished"<< endl; 
} 
beep!, number = 0 
beep!, number = 1 
beep!, number = 2 
beep!, number = 3 
beep!, number = 9 
beep!, number = 455343 
Un-infinte loop! 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 66; 
intc = 5; 
for(inti = 0;; i++ ) 
{ 
cout << "beep!, number = "<< i << endl; 
i++; 
} 
cout << "finished"<< endl; 
} 
beep!, number = 0 
beep!, number = 2 
beep!, number = 4 
beep!, number = 6 
beep!, number = 10 
beep!, number = 455340 
infinte loop!
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 66; 
intc = 5; 
for( ) 
{ 
cout << "beep!, number = "<< i << endl; 
} 
cout << "finished"<< endl; 
} 
Compiler error 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 66; 
intc = 5; 
for(i = 2; i<5; i++ ) 
{ 
cout << "beep!, number = "<< i << endl; 
} 
cout << "finished"<< endl; 
} 
beep!, number = 2 
beep!, number = 3 
beep!, number = 4 
finished 
Press any key to continue
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 66; 
intc = 5; 
for(inti = 0, j = 3; i<5; i++ ) 
{ 
cout << "beep!, number = "<< j++ << endl; 
} 
cout << "finished"<< endl; 
} 
beep!, number = 3 
beep!, number = 4 
beep!, number = 5 
beep!, number = 6 
beep!, number = 7 
finished 
Press any key to continue 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 66; 
intc = 5; 
for(inti = 0; j = 3; i<5; i++ ) 
{ 
cout << "beep!, number = "<< j++ << endl; 
} 
cout << "finished"<< endl; 
} 
Compiler error ; and not,
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 66; 
intc = 5; 
for(inti = 0,intj = 3; i<5; i++ ) 
{ 
cout << "beep!, number = "<< j++ << endl; 
} 
cout << "finished"<< endl; 
} 
Compiler error 
j undeclared identifier 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 66; 
intc = 5; 
intj = 2; 
for(inti = 0, j; i<5; i++, j--) 
{ 
cout << j << endl; 
} 
} 
0 
-1 
-2 
-3 
-4
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
for(inti = 0; i<5; i++ ) 
{ 
cout << i++ << endl; 
if( i == 34) 
{ 
break; 
} 
} 
} 
0 
0 
0 
0 
0 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
for(inti = 0; i<5; i++ ) 
{ 
cout << i++ << endl; 
break; 
} 
} 
0
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 66; 
intc = 5; 
intj = 4; 
for(inti = 0, j=0; i<5; i++, j--) 
{ 
cout << j++ << endl; 
} 
} 
0 
2 
4 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
for(inti = 0; i<5; i++ ) 
{ 
cout << i << endl; 
if( i == 34) 
{ 
break; 
} 
} 
} 
0 
1 
2 
3 
4
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
for(inti = 0; i<5; i++ ) 
{ 
cout << i << endl; 
if( i == 2) 
{ 
break; 
} 
} 
} 
0 
1 
2 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
for(inti = 0; i<5; i++ ) 
{ 
if( i == 2) 
{ 
break; 
} 
cout << i << endl; 
} 
} 
0 
1
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
for(inti = 0; i<5; i++ ) 
{ 
cout << i << endl; 
if( i = = 2) 
{ 
break; 
} 
} 
} 
Compiler error, = = not == 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
for(inti = 0; i<5; i++ ) 
{ 
cout << i << endl; 
if( i == 2) 
{ 
cout << "WEWEEEE!!!!“; 
break; 
} 
} 
} 
0 
1 
2 
WEWEEEE!!!!
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
for(inti = 0; i<5; i++ ) 
{ 
if( i == 2) 
{ 
continue; 
} 
cout << i << endl; 
} 
} 
0 
1 
3 
4 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
for(inti = 0; i<5; i++ ) 
{ 
if( i == 2) 
{ 
continue; 
cour << “WeeWeee” << endl; 
} 
cout << i << endl; 
} 
} 
0 
1 
3 
4
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
for(inti = 0; i<5; i++ ) 
{ 
cout << i << endl; 
if( i == 2) 
{ 
cout << "WeeeWeee"<< endl; 
continue; 
} 
} 
} 
0 
1 
2 
WeeeWeee 
3 
4 
Press any key to continue 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
for(inti = 0; i<5; i++ ) 
{ 
cout << i << endl; 
if( i == 2) 
{ 
cout << "WeeeWeee"<< endl; 
} 
} 
} 
0 
1 
2 
WeeeWeee 
3 
4 
Press any key to continue
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 3; 
cout << "Enter x: "<< endl; 
cin >> x; 
cout << "You have entered, x = "<< x << endl; 
switch(x) 
{ 
case1: 
cout << "WOW, i can't believe it!, you entered x = 1“ << endl; 
break; 
case2: 
cout << "WOW, i can't believe it!, you entered x = 2"<< endl; 
break; 
} 
} 
Enter x: 
2 
You have entered, x = 2 
WOW, i can't believe it!, you entered x = 2 
Press any key to continue
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 3; 
cout << "Enter x: "<< endl; 
cin >> x; 
cout << "You have entered, x = "<< x << endl; 
switch(x) 
{ 
case1: 
cout << "WOW, i can't believe it, you entered x = 1“ << endl; 
break; 
case2: 
cout << "WOW, i can't believe it, you entered x = 2"<< endl; 
break; 
} 
} 
Enter x: 
4 
You have entered, x = 2 
Press any key to continue
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 3; 
cout << "Enter x: "<< endl; 
cin >> x; 
cout << "You have entered, x = "<< x << endl; 
switch(x) 
{ 
case1: 
cout << "WOW, i can't believe it, you entered x = 1"<< endl; 
break; 
case2: 
cout << "WOW, i can't believe it, you entered x = 2"<< endl; 
break; 
default: 
cout << "Not a 1 or 2 "<< endl; 
break; 
} 
} 
Enter x: 
3 
You have entered, x = 3 
Not a 1 or 2 
Press any key to continue
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 3; 
cout << "Enter x: "<< endl; 
cin >> x; 
cout << "You have entered, x = "<< x << endl; 
switch(x) 
{ 
case1: 
cout << "WOW, i can't believe it, you entered x = 1"<< endl; 
break; 
case2: 
cout << "WOW, i can't believe it, you entered x = 2"<< endl; 
break; 
default: 
cout << "Not a 1 or 2 "<< endl; 
} 
} 
Enter x: 
3 
You have entered, x = 3 
Not a 1 or 2 
Press any key to continue
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 3; 
cout << "Enter x: "<< endl; 
cin >> x; 
cout << "You have entered, x = "<< x << endl; 
switch(x) 
{ 
case1: 
cout << "WOW, i can't believe it, you entered x = 1" 
<< endl; 
case2: 
cout << "WOW, i can't believe it, you entered x = 2" 
<< endl; 
default: 
cout << "Not a 1 or 2 "<< endl; 
} 
} 
Enter x: 
1 
You have entered, x = 1 
WOW, i can't believe it, you entered x = 1 
WOW, i can't believe it, you entered x = 2 
Not a 1 or 2 
Press any key to continue
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 3; 
cout << "Enter x: "<< endl; 
cin >> x; // 1 
cout << "You have entered, x = "<< x << endl; 
switch(x) 
{ 
case1: 
cout << "WOW, i can't believe it, you entered x = 1"<< endl; 
cout << x++ << endl; 
case2: 
cout << "WOW, i can't believe it, you entered x = 2"<< endl; 
default: 
cout << "Not a 1 or 2 "<< endl; 
} 
} 
Enter x: 
1 
You have entered, x = 1 
WOW, i can't believe it, you entered x = 1 
1 
WOW, i can't believe it, you entered x = 2 
Not a 1 or 2 
Press any key to continue
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 3; 
cout << "Enter x: "<< endl; 
cin >> x; 
cout << "You have entered, x = "<< x << endl; 
switch(x) 
{ 
case1: 
cout << "WOW, i can't believe it, you entered x = 1"<< endl; 
cout << x++ << endl; 
break; 
case2: 
cout << "WOW, i can't believe it, you entered x = 2"<< endl; 
break; 
default: 
cout << "Not a 1 or 2 "<< endl; 
} 
} 
Enter x: 
1 
You have entered, x = 1 
WOW, i can't believe it, you entered x = 1 
1 
Press any key to continue
Control Structure 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 3; 
if(x) 
cout << x << endl; 
} 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 0; 
if(x) 
cout << x << endl; 
} 
3
Your First Quiz!
Quiz
Quiz 1, 2 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
intx = 5; 
while(x!= 10) 
{ 
cout << x*x << endl; 
} 
} 
25 
25 
Indefinitely 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 0; 
intc = 5; 
do 
{ 
++c; 
cout << "beep!, number = "<< i << endl; 
i++; 
} while( c++ <= 10 ); 
} 
beep!, number = 0 
beep!, number = 1 
beep!, number = 2 
beep!, number = 3 
Press any key to continue
Quiz 3, 4 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
inti = 66; 
intc = 5; 
intj = 2; 
for(inti = 0, j; i<5; i++, j--) 
{ 
cout << ++j << endl; 
} 
} 
1 
1 
1 
1 
1 
#include<iostream> 
usingnamespace::std; 
voidmain(void) 
{ 
for(inti = 0; i<5; i++ ) 
{ 
cout << ++i << endl; 
if(i = 34) 
{ 
break; 
} 
} 
} 
1
Quiz 5, 6 
#include<iostream> 
usingnamespace::std; 
intx = 0; 
floatf2 (intz ) 
{ 
cout << z << endl; 
z*=2; 
returnz; 
} 
voidf1 ( int&x ) 
{ 
x+2; 
cout << x << endl; 
f2(x); 
cout << x << endl; 
} 
voidmain(void) 
{ 
intx = 4; 
cout <<::x++ << endl; 
f1(x); 
f1(::x); 
cout << ++::x << endl; 
} 
0 
4 
4 
4 
1 
1 
1 
2 
#include<iostream> 
usingnamespace::std; 
ints = 0; 
intSum(intn) 
{ 
if(n == 1 ) 
return1; 
else 
{ 
::s =::s + n + Sum(n-1); 
} 
} 
voidmain(void) 
{ 
cout << Sum(4) << endl; 
cout <<::s << endl; 
} 
0 
4
Quiz 7 
0000000000000000000000000000000000000000000 
0000000000000000000000000000000000000000000 
0000000000000000000000000000000000000000000 
0000000000000000000000000000000000000000000 
000000000000000000 indefinitely 
#include<iostream> 
usingnamespace::std; 
voidmain() 
{ 
enumCars { Nissan = 1, BMW, Mercedes = 1, Ferrari, Renault }; 
Cars MyCars; 
for(inti=0; i=10; i++) 
{ 
cout<< MyCars; 
} 
}

Contenu connexe

Tendances

Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...ssuserd6b1fd
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...ssuserd6b1fd
 
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and LoopsPython Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and LoopsP3 InfoTech Solutions Pvt. Ltd.
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...ssuserd6b1fd
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTsKevlin Henney
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101premrings
 
13 Strings and Text Processing
13 Strings and Text Processing13 Strings and Text Processing
13 Strings and Text ProcessingIntro C# Book
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th StudyChris Ohk
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...ssuserd6b1fd
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st StudyChris Ohk
 
C++ Lambda and concurrency
C++ Lambda and concurrencyC++ Lambda and concurrency
C++ Lambda and concurrency명신 김
 
Modern C++ Concurrency API
Modern C++ Concurrency APIModern C++ Concurrency API
Modern C++ Concurrency APISeok-joon Yun
 
C tech questions
C tech questionsC tech questions
C tech questionsvijay00791
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd StudyChris Ohk
 

Tendances (20)

C++ L09-Classes Part2
C++ L09-Classes Part2C++ L09-Classes Part2
C++ L09-Classes Part2
 
c programming
c programmingc programming
c programming
 
Unit 3
Unit 3 Unit 3
Unit 3
 
c programming
c programmingc programming
c programming
 
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
Notes for C++ Programming / Object Oriented C++ Programming for MCA, BCA and ...
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
 
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and LoopsPython Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and Loops
 
C++ L10-Inheritance
C++ L10-InheritanceC++ L10-Inheritance
C++ L10-Inheritance
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 5 of 5 by...
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
13 Strings and Text Processing
13 Strings and Text Processing13 Strings and Text Processing
13 Strings and Text Processing
 
C++ Pointers
C++ PointersC++ Pointers
C++ Pointers
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5  b...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 3 of 5 b...
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st Study
 
C++ Lambda and concurrency
C++ Lambda and concurrencyC++ Lambda and concurrency
C++ Lambda and concurrency
 
Modern C++ Concurrency API
Modern C++ Concurrency APIModern C++ Concurrency API
Modern C++ Concurrency API
 
C tech questions
C tech questionsC tech questions
C tech questions
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
 

En vedette

En vedette (6)

types of computer and software
types of computer and softwaretypes of computer and software
types of computer and software
 
Control structure C++
Control structure C++Control structure C++
Control structure C++
 
System software and Application software
System software and Application softwareSystem software and Application software
System software and Application software
 
04 software system and application software
04 software   system and application software04 software   system and application software
04 software system and application software
 
Computer Software
Computer SoftwareComputer Software
Computer Software
 
Computer Software & its Types
Computer Software & its Types Computer Software & its Types
Computer Software & its Types
 

Similaire à C++ L03-Control Structure

ch5_additional.ppt
ch5_additional.pptch5_additional.ppt
ch5_additional.pptLokeshK66
 
how to reuse code
how to reuse codehow to reuse code
how to reuse codejleed1
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2rohassanie
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloadingkinan keshkeh
 
Assignement of programming & problem solving(3)a.z
Assignement of programming & problem solving(3)a.zAssignement of programming & problem solving(3)a.z
Assignement of programming & problem solving(3)a.zSyed Umair
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++Dendi Riadi
 
Language is C++ I'm having trouble making my code meet these requireme.docx
Language is C++ I'm having trouble making my code meet these requireme.docxLanguage is C++ I'm having trouble making my code meet these requireme.docx
Language is C++ I'm having trouble making my code meet these requireme.docxrennaknapp
 

Similaire à C++ L03-Control Structure (20)

ch5_additional.ppt
ch5_additional.pptch5_additional.ppt
ch5_additional.ppt
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
Oop object oriented programing topics
Oop object oriented programing topicsOop object oriented programing topics
Oop object oriented programing topics
 
MUST CS101 Lab11
MUST CS101 Lab11 MUST CS101 Lab11
MUST CS101 Lab11
 
Project in programming
Project in programmingProject in programming
Project in programming
 
Ch4
Ch4Ch4
Ch4
 
how to reuse code
how to reuse codehow to reuse code
how to reuse code
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
 
C++ file
C++ fileC++ file
C++ file
 
C++ file
C++ fileC++ file
C++ file
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
10 template code program
10 template code program10 template code program
10 template code program
 
C++ TUTORIAL 1
C++ TUTORIAL 1C++ TUTORIAL 1
C++ TUTORIAL 1
 
Assignement of programming & problem solving(3)a.z
Assignement of programming & problem solving(3)a.zAssignement of programming & problem solving(3)a.z
Assignement of programming & problem solving(3)a.z
 
C++ practical
C++ practicalC++ practical
C++ practical
 
Nested loops
Nested loopsNested loops
Nested loops
 
Tugas praktikukm pemrograman c++
Tugas praktikukm  pemrograman c++Tugas praktikukm  pemrograman c++
Tugas praktikukm pemrograman c++
 
C++ TUTORIAL 3
C++ TUTORIAL 3C++ TUTORIAL 3
C++ TUTORIAL 3
 
Language is C++ I'm having trouble making my code meet these requireme.docx
Language is C++ I'm having trouble making my code meet these requireme.docxLanguage is C++ I'm having trouble making my code meet these requireme.docx
Language is C++ I'm having trouble making my code meet these requireme.docx
 
C++ file
C++ fileC++ file
C++ file
 

Plus de Mohammad Shaker

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian GraduateMohammad Shaker
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Mohammad Shaker
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyMohammad Shaker
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015Mohammad Shaker
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game DevelopmentMohammad Shaker
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesMohammad Shaker
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - ColorMohammad Shaker
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - TypographyMohammad Shaker
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingMohammad Shaker
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and ThreadingMohammad Shaker
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSMohammad Shaker
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsMohammad Shaker
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsMohammad Shaker
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and GamingMohammad Shaker
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / ParseMohammad Shaker
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesMohammad Shaker
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes Mohammad Shaker
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and AdaptersMohammad Shaker
 

Plus de Mohammad Shaker (20)

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with Psychology
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game Development
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and Wearables
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - Color
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - Typography
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and Coupling
 
Android L05 - Storage
Android L05 - StorageAndroid L05 - Storage
Android L05 - Storage
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and Threading
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOS
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile Constraints
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and Grids
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and Gaming
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / Parse
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and Utilities
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and Adapters
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 

Dernier

Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfsmsksolar
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projectssmsksolar
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksMagic Marks
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxmaisarahman1
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadhamedmustafa094
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxnuruddin69
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 

Dernier (20)

Rums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdfRums floating Omkareshwar FSPV IM_16112021.pdf
Rums floating Omkareshwar FSPV IM_16112021.pdf
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic Marks
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 

C++ L03-Control Structure

  • 1. C++ Programming Language L03-CONTROL STRUCTURE Mohammad Shaker mohammadshaker.com @ZGTRShaker 2010, 11, 12, 13, 14
  • 3. Control Structure •If else •While •do while –Executed at least once whatever the condition is. •for •switch
  • 4. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 4; if( x == 4 ) { cout << "True "<< endl; } else { cout << "False "<< endl; } } True #include<iostream> usingnamespace::std; voidmain(void) { intx = 4; if( x = 4 ) { cout << "True "<< endl; } else { cout << "False "<< endl; } } True
  • 5. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 4; if( x = 5 ) { cout << "True "<< endl; } else { cout << "False "<< endl; } } True #include<iostream> usingnamespace::std; voidmain(void) { intx = 4; if( x!= 4 ) { cout << "True "<< endl; } else { cout << "False "<< endl; } } False
  • 6. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 4; if( x == 4 ) cout << "True "<< endl; else cout << "False "<< endl; cout << "foo"<< endl; } True foo #include<iostream> usingnamespace::std; ints=0; voidmain(void) { intx=0; if(x=0) { cout<<"joo"<<endl; } cout<<"yoo"<<endl; system("pause"); } yoo Every other number other than 0 means true
  • 7. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 5; while(x!= 10) { x++; cout << x << endl; } } 6 7 8 9 10 #include<iostream> usingnamespace::std; voidmain(void) { intx = 5; while(x!= 10) { cout << x++ << endl; } } 5 6 7 8 9
  • 8. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 5; while(x!= 10) { cout << ++x << endl; } } 6 7 8 9 10 #include<iostream> usingnamespace::std; voidmain(void) { intx = 5; while(x!= 10) { ++x; cout << x << endl; } } 6 7 8 9 10
  • 9. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 5; while(x < 10) { cout << x*x << endl; } } 25 25 Indefinitely #include<iostream> usingnamespace::std; voidmain(void) { intx = 5; while(x*x < 10) { cout << x*x << endl; } }
  • 10. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 5; while(cin) { cin >> x; cout << x*x << endl; } } 2 4 4 16 6 36 8 64 1 1 2 4 ^Z 4 Press any key to continue #include<iostream> usingnamespace::std; voidmain(void) { intx = 5; do { cout << x << endl; x++; } while( x < 10 ); } 5 6 7 8 9 Press any key to continue
  • 11. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 5; do { cout << x << endl; x++; } while( x < 10 ) } Compiler error, missing “;” after the while(); #include<iostream> usingnamespace::std; voidmain(void) { intx = 5; do { cout << x << endl; } while( x < 4 ); } 5 do while execute at least one, eventhough the condition is not fulfilled.
  • 12. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 5; do { cout << "Enter the x:"<< endl; cin >> x; cout << "You have entered, x = "<< x << endl; cout << "____________________________" << endl; } while( x!= 0 ); } Enter the x: 2 You have entered, x = 2 ________________________________ Enter the x: 3 You have entered, x = 3 ________________________________ Enter the x: 4 You have entered, x = 4 ________________________________ Enter the x: 23 You have entered, x = 23 ________________________________ Enter the x: 0 You have entered, x = 0 ________________________________ Press any key to continue
  • 13. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { inti = 0; intc = 5; do { ++c; cout << "beep!, number = "<< i << endl; i++; } while( ++c < 10 ); } beep!, number = 0 beep!, number = 1 beep!, number = 2 Press any key to continue #include<iostream> usingnamespace::std; voidmain(void) { inti = 0; intc = 5; do { ++c; cout << "beep!, number = "<< i << endl; i++; } while( c++ < 10 ); } beep!, number = 0 beep!, number = 1 beep!, number = 2 Press any key to continue
  • 14. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { inti = 0; intc = 5; do { ++c; cout << "beep!, number = "<< i << endl; i++; } while( ++c <= 10 ); } beep!, number = 0 beep!, number = 1 beep!, number = 2 Press any key to continue
  • 16. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { for(inti = 0; i < 10; i++) { cout<<"beep!, number = “<<i<<endl; } cout << "finished"<< endl; } beep!, number = 0 beep!, number = 1 beep!, number = 2 beep!, number = 3 beep!, number = 4 beep!, number = 5 beep!, number = 6 beep!, number = 7 beep!, number = 8 beep!, number = 9 finished Press any key to continue #include<iostream> usingnamespace::std; voidmain(void) { inti = 5; for(inti = 0; i < 10; i++) { cout << "beep!, number = "<< i << endl; } cout << "finished"<< endl; } beep!, number = 0 beep!, number = 1 beep!, number = 2 beep!, number = 3 beep!, number = 4 beep!, number = 5 beep!, number = 6 beep!, number = 7 beep!, number = 8 beep!, number = 9 finished Press any key to continue
  • 17. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { inti = 5; intc = 5; for(inti = 0; i < 10; i++) { cout << "beep!, number = “ << i << endl; i++; } cout << "finished"<< endl; } beep!, number = 0 beep!, number = 2 beep!, number = 4 beep!, number = 6 beep!, number = 8 finished #include<iostream> usingnamespace::std; voidmain(void) { inti = 66; intc = 5; for(inti = 0; i < 10; i++); { cout << "beep!, number = "<< i << endl; i++; } cout << "finished"<< endl; } beep!, number = 66 finished Press any key to continue Watch out for the semi colon “;” after the for statement Coz it close it
  • 18. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { inti = 66; intc = 5; for(inti = 0; i < 10; ) { cout << "beep!, number = "<< i << endl; i++; } cout << "finished"<< endl; } beep!, number = 0 beep!, number = 1 beep!, number = 2 beep!, number = 3 beep!, number = 4 beep!, number = 5 beep!, number = 6 beep!, number = 7 beep!, number = 8 beep!, number = 9 finished Press any key to continue #include<iostream> usingnamespace::std; voidmain(void) { inti = 66; intc = 5; for(inti = 0; i < 10; ); { cout << "beep!, number = "<< i << endl; i++; } cout << "finished"<< endl; } infinte loop, Nothing to print
  • 19. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { inti = 66; intc = 5; for(inti = 0;; ) { cout << "beep!, number = "<< i << endl; i++; } cout << "finished"<< endl; } beep!, number = 0 beep!, number = 1 beep!, number = 2 beep!, number = 3 beep!, number = 9 beep!, number = 455343 Un-infinte loop! #include<iostream> usingnamespace::std; voidmain(void) { inti = 66; intc = 5; for(inti = 0;; i++ ) { cout << "beep!, number = "<< i << endl; i++; } cout << "finished"<< endl; } beep!, number = 0 beep!, number = 2 beep!, number = 4 beep!, number = 6 beep!, number = 10 beep!, number = 455340 infinte loop!
  • 20. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { inti = 66; intc = 5; for( ) { cout << "beep!, number = "<< i << endl; } cout << "finished"<< endl; } Compiler error #include<iostream> usingnamespace::std; voidmain(void) { inti = 66; intc = 5; for(i = 2; i<5; i++ ) { cout << "beep!, number = "<< i << endl; } cout << "finished"<< endl; } beep!, number = 2 beep!, number = 3 beep!, number = 4 finished Press any key to continue
  • 21. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { inti = 66; intc = 5; for(inti = 0, j = 3; i<5; i++ ) { cout << "beep!, number = "<< j++ << endl; } cout << "finished"<< endl; } beep!, number = 3 beep!, number = 4 beep!, number = 5 beep!, number = 6 beep!, number = 7 finished Press any key to continue #include<iostream> usingnamespace::std; voidmain(void) { inti = 66; intc = 5; for(inti = 0; j = 3; i<5; i++ ) { cout << "beep!, number = "<< j++ << endl; } cout << "finished"<< endl; } Compiler error ; and not,
  • 22. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { inti = 66; intc = 5; for(inti = 0,intj = 3; i<5; i++ ) { cout << "beep!, number = "<< j++ << endl; } cout << "finished"<< endl; } Compiler error j undeclared identifier #include<iostream> usingnamespace::std; voidmain(void) { inti = 66; intc = 5; intj = 2; for(inti = 0, j; i<5; i++, j--) { cout << j << endl; } } 0 -1 -2 -3 -4
  • 23. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { for(inti = 0; i<5; i++ ) { cout << i++ << endl; if( i == 34) { break; } } } 0 0 0 0 0 #include<iostream> usingnamespace::std; voidmain(void) { for(inti = 0; i<5; i++ ) { cout << i++ << endl; break; } } 0
  • 24. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { inti = 66; intc = 5; intj = 4; for(inti = 0, j=0; i<5; i++, j--) { cout << j++ << endl; } } 0 2 4 #include<iostream> usingnamespace::std; voidmain(void) { for(inti = 0; i<5; i++ ) { cout << i << endl; if( i == 34) { break; } } } 0 1 2 3 4
  • 25. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { for(inti = 0; i<5; i++ ) { cout << i << endl; if( i == 2) { break; } } } 0 1 2 #include<iostream> usingnamespace::std; voidmain(void) { for(inti = 0; i<5; i++ ) { if( i == 2) { break; } cout << i << endl; } } 0 1
  • 26. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { for(inti = 0; i<5; i++ ) { cout << i << endl; if( i = = 2) { break; } } } Compiler error, = = not == #include<iostream> usingnamespace::std; voidmain(void) { for(inti = 0; i<5; i++ ) { cout << i << endl; if( i == 2) { cout << "WEWEEEE!!!!“; break; } } } 0 1 2 WEWEEEE!!!!
  • 27. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { for(inti = 0; i<5; i++ ) { if( i == 2) { continue; } cout << i << endl; } } 0 1 3 4 #include<iostream> usingnamespace::std; voidmain(void) { for(inti = 0; i<5; i++ ) { if( i == 2) { continue; cour << “WeeWeee” << endl; } cout << i << endl; } } 0 1 3 4
  • 28. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { for(inti = 0; i<5; i++ ) { cout << i << endl; if( i == 2) { cout << "WeeeWeee"<< endl; continue; } } } 0 1 2 WeeeWeee 3 4 Press any key to continue #include<iostream> usingnamespace::std; voidmain(void) { for(inti = 0; i<5; i++ ) { cout << i << endl; if( i == 2) { cout << "WeeeWeee"<< endl; } } } 0 1 2 WeeeWeee 3 4 Press any key to continue
  • 29. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 3; cout << "Enter x: "<< endl; cin >> x; cout << "You have entered, x = "<< x << endl; switch(x) { case1: cout << "WOW, i can't believe it!, you entered x = 1“ << endl; break; case2: cout << "WOW, i can't believe it!, you entered x = 2"<< endl; break; } } Enter x: 2 You have entered, x = 2 WOW, i can't believe it!, you entered x = 2 Press any key to continue
  • 30. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 3; cout << "Enter x: "<< endl; cin >> x; cout << "You have entered, x = "<< x << endl; switch(x) { case1: cout << "WOW, i can't believe it, you entered x = 1“ << endl; break; case2: cout << "WOW, i can't believe it, you entered x = 2"<< endl; break; } } Enter x: 4 You have entered, x = 2 Press any key to continue
  • 31. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 3; cout << "Enter x: "<< endl; cin >> x; cout << "You have entered, x = "<< x << endl; switch(x) { case1: cout << "WOW, i can't believe it, you entered x = 1"<< endl; break; case2: cout << "WOW, i can't believe it, you entered x = 2"<< endl; break; default: cout << "Not a 1 or 2 "<< endl; break; } } Enter x: 3 You have entered, x = 3 Not a 1 or 2 Press any key to continue
  • 32. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 3; cout << "Enter x: "<< endl; cin >> x; cout << "You have entered, x = "<< x << endl; switch(x) { case1: cout << "WOW, i can't believe it, you entered x = 1"<< endl; break; case2: cout << "WOW, i can't believe it, you entered x = 2"<< endl; break; default: cout << "Not a 1 or 2 "<< endl; } } Enter x: 3 You have entered, x = 3 Not a 1 or 2 Press any key to continue
  • 33. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 3; cout << "Enter x: "<< endl; cin >> x; cout << "You have entered, x = "<< x << endl; switch(x) { case1: cout << "WOW, i can't believe it, you entered x = 1" << endl; case2: cout << "WOW, i can't believe it, you entered x = 2" << endl; default: cout << "Not a 1 or 2 "<< endl; } } Enter x: 1 You have entered, x = 1 WOW, i can't believe it, you entered x = 1 WOW, i can't believe it, you entered x = 2 Not a 1 or 2 Press any key to continue
  • 34. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 3; cout << "Enter x: "<< endl; cin >> x; // 1 cout << "You have entered, x = "<< x << endl; switch(x) { case1: cout << "WOW, i can't believe it, you entered x = 1"<< endl; cout << x++ << endl; case2: cout << "WOW, i can't believe it, you entered x = 2"<< endl; default: cout << "Not a 1 or 2 "<< endl; } } Enter x: 1 You have entered, x = 1 WOW, i can't believe it, you entered x = 1 1 WOW, i can't believe it, you entered x = 2 Not a 1 or 2 Press any key to continue
  • 35. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 3; cout << "Enter x: "<< endl; cin >> x; cout << "You have entered, x = "<< x << endl; switch(x) { case1: cout << "WOW, i can't believe it, you entered x = 1"<< endl; cout << x++ << endl; break; case2: cout << "WOW, i can't believe it, you entered x = 2"<< endl; break; default: cout << "Not a 1 or 2 "<< endl; } } Enter x: 1 You have entered, x = 1 WOW, i can't believe it, you entered x = 1 1 Press any key to continue
  • 36. Control Structure #include<iostream> usingnamespace::std; voidmain(void) { intx = 3; if(x) cout << x << endl; } #include<iostream> usingnamespace::std; voidmain(void) { intx = 0; if(x) cout << x << endl; } 3
  • 38. Quiz
  • 39. Quiz 1, 2 #include<iostream> usingnamespace::std; voidmain(void) { intx = 5; while(x!= 10) { cout << x*x << endl; } } 25 25 Indefinitely #include<iostream> usingnamespace::std; voidmain(void) { inti = 0; intc = 5; do { ++c; cout << "beep!, number = "<< i << endl; i++; } while( c++ <= 10 ); } beep!, number = 0 beep!, number = 1 beep!, number = 2 beep!, number = 3 Press any key to continue
  • 40. Quiz 3, 4 #include<iostream> usingnamespace::std; voidmain(void) { inti = 66; intc = 5; intj = 2; for(inti = 0, j; i<5; i++, j--) { cout << ++j << endl; } } 1 1 1 1 1 #include<iostream> usingnamespace::std; voidmain(void) { for(inti = 0; i<5; i++ ) { cout << ++i << endl; if(i = 34) { break; } } } 1
  • 41. Quiz 5, 6 #include<iostream> usingnamespace::std; intx = 0; floatf2 (intz ) { cout << z << endl; z*=2; returnz; } voidf1 ( int&x ) { x+2; cout << x << endl; f2(x); cout << x << endl; } voidmain(void) { intx = 4; cout <<::x++ << endl; f1(x); f1(::x); cout << ++::x << endl; } 0 4 4 4 1 1 1 2 #include<iostream> usingnamespace::std; ints = 0; intSum(intn) { if(n == 1 ) return1; else { ::s =::s + n + Sum(n-1); } } voidmain(void) { cout << Sum(4) << endl; cout <<::s << endl; } 0 4
  • 42. Quiz 7 0000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000 000000000000000000 indefinitely #include<iostream> usingnamespace::std; voidmain() { enumCars { Nissan = 1, BMW, Mercedes = 1, Ferrari, Renault }; Cars MyCars; for(inti=0; i=10; i++) { cout<< MyCars; } }