際際滷

際際滷Share a Scribd company logo
油
Control Statements 犖犖劇賢犖犖犖萎犖∇犖犖朽犢犖犢犢犖犖犖迦牽犖犖橿犖犖巌犖犖迦牽犖犖犖犢犖犖犢犖犖犖÷犖犢犖犖犖巌絹犖犖迦犖犖朽犖犢犖犖犖犖迦牽 犖犖朽犖犖犖犢犖犖犖劇賢犢犖犖犖迦犖犖迦牽犖犖橿犖犖巌犖犖迦牽犢犖犖ム験犖犖園  (sequence )  犖犖犖犖犖犖萎犖∇犖犖犖劇賢犖犖橿肩犖園犖犖犖犖犖 犢犖犢犖犖犖犖犢犖犢犖  if  statement switch  statement while  statement do  statement for  statement break  statement continue  statement
犖犖犖萎犖∇  if  犢犖犢犖犖о犖犖伍検犢犖犖犢犖犖犖÷犖ム厳犖犖犖犖橿犖犖巌犖犖迦牽犢犖犢犖犢犖犢犖犖犖迦犢犖犢犖犢犖犖犖迦犖犖犖謹犖犖犖萎見犖о犖迦犖犖迦犢犖ム厳犖犖犖犖犖犖犖迦 犢犖犖∇犖犢犖犖ム犖犖  < boolean expression>  犢犖犢犖犖犖園犖犖巌犢犖犢犖犖犖犖犖犢犖迦犖犖犖犖犖犖萎犖∇ 犢犖犖∇検犖朽牽犖項犢犖犖犖犖犖犖犖犖萎犖∇犖犖園犖犖朽 if statement if (<boolean expression>)  <statement>; [  else <statement>; ]
#include<iostram.h> void main( ) { int  n;  cout<< Enter number :: >>  ; cin>>n; if( n = = 0)  cout<<Zero Number   ; if( n > 0) cout<< Positive Number   ; else  cout<< Negative Number  ; }
if  statement Statement 1 expression Statement 2 false true expression Statement 3 true Statement 2 false Statement 1 犢犖犖犖犖朽  1 犢犖犖犖犖朽  2
#include<iostream> using namespace std; void main(){ int x = 0; if ( 1 ) cout<<&quot;print 1&quot;<<endl;  if ( !x ) cout<<&quot;!x&quot;<<endl; else cout<<&quot;x&quot;<<endl; }
犖犖迦牽犢犖犖犖朽権犖犢犖犖朽権犖犖犖園硯犢犖ム 犖犢犖迦牽犖園犖犢犖迦検犖  5  犖犢犖 犢犖犖  n0,n1,n2,n3,n4  犢犖ム犖о見犖迦硯犢犖迦犢犖迦犖犖÷顕犖犖犖朽犖犖伍犖犢犖迦犖 犖犢犖犖∇犖朽犖犖伍  ( 犢犖犖о犖巌犖犖橿賢犖∇犖迦犢犖 ) 犖犢犖迦検犖朽犖園硯犢犖ム犢犖÷犖犢犖橿犢犖迦犖巌犖犖犖ム弦犖犖犖犖  5  犖ム弦犖 犢犖犢犢犖о犢犖犖犖伍犖犖橿犖ム犖о犖犢犖犖∇鹸犖犖÷顕犖犖 犖ム鍵犖ム弦犖犢犖犖劇犖犖犖迦献犖項犖犖朽犖÷元犖犢犖迦検犖迦犖犖朽犖犖伍犢犖ム鍵犖犢犖犖∇犖朽犖犖伍 犖犖橿犖迦検  犖犖萎犢犖犖犖犖∇鹸犖犖犖朽犖犖犖園犖 犢犖ム鍵 犖÷元犖о鹸犖犖朽犖迦牽犖犖∇犖迦犢犖犢犖犖犖迦牽犖犖迦献犖項犖犖朽犖犢犖犖∇犖朽犖犖伍犢犖ム鍵犖÷顕犖犖犖朽犖犖伍
MAX =  MIN =  1 犖犢犖迦検犖朽犖園硯犢犖ム犢犖÷犖犢犖橿犢犖迦犖巌犖犖犖ム弦犖犖犖犖  5  犖ム弦犖 犢犖犢犖犖迦犖ム犖犖朽犖犢犖犖∇犖朽犖犖伍犢犖ム鍵犖÷顕犖 犖犖朽犖犖伍犖犖朽犖犖巌犖犖犖犖伍犖犖犖 犖犖萎犖橿賢犖∇犖迦犢犖  !!!
MAX =  MIN =  2 犖犢犖迦検犖朽犖園硯犢犖ム犢犖÷犖犢犖橿犢犖迦犖巌犖犖犖ム弦犖犖犖犖  5  犖ム弦犖 犢犖犢犖犖迦犖ム犖犖朽犖犢犖犖∇犖朽犖犖伍犢犖ム鍵犖÷顕犖 犖犖朽犖犖伍犖犖朽犖犖巌犖犖犖犖伍犖犖犖 犖犖萎犖橿賢犖∇犖迦犢犖  !!!
MAX =  MIN =  3 犖犢犖迦検犖朽犖園硯犢犖ム犢犖÷犖犢犖橿犢犖迦犖巌犖犖犖ム弦犖犖犖犖  5  犖ム弦犖 犢犖犢犖犖迦犖ム犖犖朽犖犢犖犖∇犖朽犖犖伍犢犖ム鍵犖÷顕犖 犖犖朽犖犖伍犖犖朽犖犖巌犖犖犖犖伍犖犖犖 犖犖萎犖橿賢犖∇犖迦犢犖  !!!
MAX =  MIN =  4 犖犢犖迦検犖朽犖園硯犢犖ム犢犖÷犖犢犖橿犢犖迦犖巌犖犖犖ム弦犖犖犖犖  5  犖ム弦犖 犢犖犢犖犖迦犖ム犖犖朽犖犢犖犖∇犖朽犖犖伍犢犖ム鍵犖÷顕犖 犖犖朽犖犖伍犖犖朽犖犖巌犖犖犖犖伍犖犖犖 犖犖萎犖橿賢犖∇犖迦犢犖  !!!
MAX =  MIN =  5 犖犢犖迦検犖朽犖園硯犢犖ム犢犖÷犖犢犖橿犢犖迦犖巌犖犖犖ム弦犖犖犖犖  5  犖ム弦犖 犢犖犢犖犖迦犖ム犖犖朽犖犢犖犖∇犖朽犖犖伍犢犖ム鍵犖÷顕犖 犖犖朽犖犖伍犖犖朽犖犖巌犖犖犖犖伍犖犖犖 犖犖萎犖橿賢犖∇犖迦犢犖  !!!
犖犖迦牽犢犖犖犖朽権犖犢犖犖朽権犖犖犖園硯犢犖ム 犖犢犖迦牽犖園犖犢犖迦検犖  5  犖犢犖 犢犖犖  n0,n1,n2,n3,n4  犢犖ム犖о見犖迦硯犢犖迦犢犖迦犖犖÷顕犖犖犖朽犖犖伍犖犢犖迦犖 犖犢犖犖∇犖朽犖犖伍  ( 犢犖犖о犖巌犖犖橿賢犖∇犖迦犢犖 ) 犖犖園犖犢犖  cin>>no; cin>>n1;cin>>n2;cin>>n3;cin>>n4  2.  犖犖橿見犖犖犢犖犢 犖犢犖迦犖犖犢犖犢犖 犖犖園硯犖犖朽犖÷顕犖犖犖朽犖犖伍 犢犖ム鍵犖犢犖犖∇犖朽犖犖伍 3.  犢犖犖犖朽権犖犢犖犖朽権犖犖犢犖迦犖園硯犖犖朽犢犖犖ム厳犖犢犖犖∇犖犖巌犖÷犖迦犖犖園硯犖犖朽  2  犢犖犖犖迦鍵犖犖園硯犢犖犖犢犖犢犖÷顕犖犢犖ム鍵犖犢犖犖∇犖朽犖犖伍犢犖犢犖ム犖 4.  犢犖犖犖犖犖ム献犖園犖犢
#include<iostream.h> void main(){ int n0,n1,n2,n3,n4; int max,min; cout<<&quot;Enter 5 numbers >> &quot;; cin>>n0;cin>>n1;cin>>n2;cin>>n3;cin>>n4; max = n0;min =n0; //round 1 if (n1>max) max=n1; if (n1<min) min=n1; //round 2 if (n2>max) max=n2; if (n2<min) min=n2; //round 3 if (n3>max) max=n3; if (n3<min) min=n3; //round 4 if (n4>max) max=n4; if (n4<min) min=n4; // Print output cout<<&quot;minimum number =  &quot;<<min<<endl; cout<<&quot;maximum number  = &quot;<<max<<endl; }
#include<iostream.h> void main(){ int n[5]; int max,min,i; cout<<&quot;==== Enter 5 numbers =====&quot;<<endl; for (i=0;i<5;i++) {  cout<<&quot;Emter number &quot;<<i+1<<&quot; >>  &quot;;cin>>n[i];//first is n[0] Not n[1]; }  max=n[0];min=n[0]; for (i=1;i<5;i++) {  if (n[i]>max) max=n[i]; if (n[i]<min) min=n[i]; }  // Print output cout<<&quot;minimum number =  &quot;<<min<<endl; cout<<&quot;maximum number  = &quot;<<max<<endl; }
For statement For ( init-expression ; cond-expression ; loop-expression ) #include<iostream.h> void main(){ int n[5]={1,2,3,4,5}; int max,min,i; for(i=1;i<=5;i++){ // i+=2 cout<<&quot;Print i value &quot;<<i<<endl; } }
int  i; for ( i = 0; i < 5; cout<<i<<endl, i++); int  i, j; for  ( i = 5, j = 10 ;  i + j < 20 ; i++, j++ )   cout<<&quot; i + j =  &quot;<<  (i+j)  <<endl;
#include<iostream.h> void main(){ int n[5]={1,2,3,4,5}; int  i; for (i=0;i<=4;i++) if (i >0) {  cout<<n[i]<<endl; i +=2; cout<<&quot;Hahaha 55555 Joke &quot;<<endl; } else { for(int j=0;j<2;j++) cout<<&quot; I am a rock&quot;<<j<<endl; } cout<<&quot;=======================================&quot;<<endl; }// 犖犖ム献犖園犖犢犖犖朽犢犖犢犖犖劇賢犖犖萎犖
犢仰犖犖朽権犖犖犖橿肩犖園犖   For statement  犢犖犖犖犖犖ム犖園犖犖朽
#include<iostream.h> void main(){ int i,j,k; cout<<&quot;Print value from 0 to 10,10 to 0 and -5 to 5 &quot;<<endl; cout<<&quot;i j k&quot;<<endl; cout<<&quot;---------------------&quot;<<endl; for(i=0,j=10,k=-5;i<=10,j>=0,k<=5;i++,j--,k++){ // for(i=0,j=0,k=-5;i<=10;i++,j--,k++){ cout<<i<<&quot;&quot;<<j<<&quot;&quot;<<k; cout<<endl; } cout<<&quot;---------------------&quot;<<endl; }
犢犖犖犖犖犖伍犖犖犖項検犖巌犖犖ム犖犖朽権犖 犢犖ム鍵犖犖迦犖犖犢犖犖犢 犢犖犖∇犖朽 Fahreheit =9*Celseius /5+32
#include<iostream.h> void main(){ //Display Celseius  and Fahrenheit float cel,fah; cout<<&quot;Celseius  Fahreheit &quot;<<endl; for(cel=0;cel<=100;cel++){ fah = 9*cel/5+32; cout<<&quot;  &quot;<<cel<<&quot;&quot;<<fah<<endl; } }
while..do and  dowhile #include <iostream.h>  int  main() { int  odd = 0, even = 0,time=0,  result; /* process 10 students; counter-controlled loop */ cout << &quot;Enter Number 0 - 9  &quot;<<endl; while (time < 10){   cout << &quot;Number &quot;<< ++time<<&quot;  >>&quot; ; cin >> result; if (result%2 == 0)  even ++; else  odd++;   } cout<<&quot;Odd = &quot;<<odd<<endl; cout<<&quot;Even = &quot;<<even<<endl; } while do 犖犖園犖犢犖 犖犖橿犖о犢犖犢犖 犖犖園犖犢犖犢  0  9  犖犖巌犖犖橿犖о 犢犖ム犖о見犖迦硯犢犖迦検犖 犖犖園硯犢犖ム犖犖項 犢犖ム鍵 犖犖朽 犖犖朽犖犖橿犖о   while do
while..do and  dowhile #include <iostream.h> int  main() { int  odd = 0, even = 0,time=0,  result; cout << &quot;Enter Number 0 - 9  &quot;<<endl; do{cout << &quot;Number &quot;<< ++time<<&quot;  >>&quot; ; cin >> result; if (result%2 == 0)  even ++; else odd++;   }while(time<10); cout<<&quot;Odd = &quot;<<odd<<endl; cout<<&quot;Even = &quot;<<even<<endl; } do..while  犖犖園犖犢犖 犖犖橿犖о犢犖犢犖 犖犖園犖犢犖犢  0  9  犖犖巌犖犖橿犖о 犢犖ム犖о見犖迦硯犢犖迦検犖 犖犖園硯犢犖ム犖犖項 犢犖ム鍵 犖犖朽 犖犖朽犖犖橿犖о  ... dowhile
犖犖迦犢犖  j k l  犖犖犖犖  犖÷元 犢犖ム鍵犢犖÷犖÷元犖犖橿肩犖園犖  break  #include <iostream.h> int  main() {int j,k,l; j=10;k=1;l=0; do{   if(j+k)   cout<<&quot;J1+K1 = &quot;<<j+k<<endl;   break;   l++;   j--; }while(k++<6); cout<<&quot;j = &quot;<<j<<&quot;  k = &quot;<<k<<&quot; l = &quot;<<l<<endl; }
#include < iostream .h> float  power3 (float); void main (void) { int i ; for (i=1; i <=10; i++) cout<< i<<  <<power3 ( i )   ); } float  power3 (float  x ) { return  x *  x   * x ; } 1 8 27 64 125 216 343 512 729 1000 Function
1.  犖犖巌犖迦牽犖犖迦犖犖犢犖犖犖÷犢犖犢犖犖犖朽 #include <iostream . h> void main () { int i, j, n; cout << &quot; Enter N  = &quot; ; cin >> n; i  =  n; while  ( i >=   1 )  { j  =  1; while  ( j < i )  { cout <<  &quot; &quot; ; j ++ ; } while  ( j < =  n )   { cout <<  &quot;*&quot; ; j ++ ; } cout <<  &quot;  &quot; ; i--; } } #include <iostream . h> void main () { int i, j, n; cout << &quot; Enter N  = &quot; ; cin >> n; for  ( i = n;i> = 1;i --) { for  ( j = 1;j<i;j ++)   cout <<  &quot; &quot; ; for  ( j = i;j< = n;j ++) cout << &quot;*&quot; ; cout <<  &quot;  &quot; ; } } 犢犖犖犖朽権犖犢犖犖朽権犖 犖犖迦牽犢犖犢  While  犢犖ム鍵  For loop
#include<iostream> using namespace std; int main() { char *buffer = &quot;Any character stream&quot;; int capa, lettera, nota; char c; capa = lettera = nota = 0; cout<<&quot;Any character stream&quot;; while ( c = *buffer++ )  // Walks buffer until NULL { switch ( c ) {  case 'A': capa++; break; case 'a': lettera++; break; default: nota++;  } } cout<<&quot;Uppercase a: &quot;<<capa<<&quot;Lowercase a: &quot;<<lettera<<&quot;Not character a: &quot;<<nota; cout<<&quot;Total:&quot;; cout<<(capa + lettera + nota)<<endl; } 犢犖犢犖犖園犖犖朽犖犖迦犖犖朽権犖犢犖犢犖犢犖犖犢犖犖犖÷犖ム犖о犖橿犖迦牽犖犖園犖о犖迦犖犢犖犢犖迦賢犖萎犖  犢犖ム犖о犖犖犖犖橿犖迦検犖о犖 犢犖犖犢犖犖犖÷犖朽犖犖橿犖迦犖犖∇犖迦犢犖犢犖犖朽権犖犖犖謹犖犖÷顕犢犖犖劇犖犖犖萎犖

More Related Content

4 control statement

  • 1.
  • 2. Control Statements 犖犖劇賢犖犖犖萎犖∇犖犖朽犢犖犢犢犖犖犖迦牽犖犖橿犖犖巌犖犖迦牽犖犖犖犢犖犖犢犖犖犖÷犖犢犖犖犖巌絹犖犖迦犖犖朽犖犢犖犖犖犖迦牽 犖犖朽犖犖犖犢犖犖犖劇賢犢犖犖犖迦犖犖迦牽犖犖橿犖犖巌犖犖迦牽犢犖犖ム験犖犖園 (sequence ) 犖犖犖犖犖犖萎犖∇犖犖犖劇賢犖犖橿肩犖園犖犖犖犖犖 犢犖犢犖犖犖犖犢犖犢犖 if statement switch statement while statement do statement for statement break statement continue statement
  • 3. 犖犖犖萎犖∇ if 犢犖犢犖犖о犖犖伍検犢犖犖犢犖犖犖÷犖ム厳犖犖犖犖橿犖犖巌犖犖迦牽犢犖犢犖犢犖犢犖犖犖迦犢犖犢犖犢犖犖犖迦犖犖犖謹犖犖犖萎見犖о犖迦犖犖迦犢犖ム厳犖犖犖犖犖犖犖迦 犢犖犖∇犖犢犖犖ム犖犖 < boolean expression> 犢犖犢犖犖犖園犖犖巌犢犖犢犖犖犖犖犖犢犖迦犖犖犖犖犖犖萎犖∇ 犢犖犖∇検犖朽牽犖項犢犖犖犖犖犖犖犖犖萎犖∇犖犖園犖犖朽 if statement if (<boolean expression>) <statement>; [ else <statement>; ]
  • 4. #include<iostram.h> void main( ) { int n; cout<< Enter number :: >> ; cin>>n; if( n = = 0) cout<<Zero Number ; if( n > 0) cout<< Positive Number ; else cout<< Negative Number ; }
  • 5. if statement Statement 1 expression Statement 2 false true expression Statement 3 true Statement 2 false Statement 1 犢犖犖犖犖朽 1 犢犖犖犖犖朽 2
  • 6. #include<iostream> using namespace std; void main(){ int x = 0; if ( 1 ) cout<<&quot;print 1&quot;<<endl; if ( !x ) cout<<&quot;!x&quot;<<endl; else cout<<&quot;x&quot;<<endl; }
  • 7. 犖犖迦牽犢犖犖犖朽権犖犢犖犖朽権犖犖犖園硯犢犖ム 犖犢犖迦牽犖園犖犢犖迦検犖 5 犖犢犖 犢犖犖 n0,n1,n2,n3,n4 犢犖ム犖о見犖迦硯犢犖迦犢犖迦犖犖÷顕犖犖犖朽犖犖伍犖犢犖迦犖 犖犢犖犖∇犖朽犖犖伍 ( 犢犖犖о犖巌犖犖橿賢犖∇犖迦犢犖 ) 犖犢犖迦検犖朽犖園硯犢犖ム犢犖÷犖犢犖橿犢犖迦犖巌犖犖犖ム弦犖犖犖犖 5 犖ム弦犖 犢犖犢犢犖о犢犖犖犖伍犖犖橿犖ム犖о犖犢犖犖∇鹸犖犖÷顕犖犖 犖ム鍵犖ム弦犖犢犖犖劇犖犖犖迦献犖項犖犖朽犖÷元犖犢犖迦検犖迦犖犖朽犖犖伍犢犖ム鍵犖犢犖犖∇犖朽犖犖伍 犖犖橿犖迦検 犖犖萎犢犖犖犖犖∇鹸犖犖犖朽犖犖犖園犖 犢犖ム鍵 犖÷元犖о鹸犖犖朽犖迦牽犖犖∇犖迦犢犖犢犖犖犖迦牽犖犖迦献犖項犖犖朽犖犢犖犖∇犖朽犖犖伍犢犖ム鍵犖÷顕犖犖犖朽犖犖伍
  • 8. MAX = MIN = 1 犖犢犖迦検犖朽犖園硯犢犖ム犢犖÷犖犢犖橿犢犖迦犖巌犖犖犖ム弦犖犖犖犖 5 犖ム弦犖 犢犖犢犖犖迦犖ム犖犖朽犖犢犖犖∇犖朽犖犖伍犢犖ム鍵犖÷顕犖 犖犖朽犖犖伍犖犖朽犖犖巌犖犖犖犖伍犖犖犖 犖犖萎犖橿賢犖∇犖迦犢犖 !!!
  • 9. MAX = MIN = 2 犖犢犖迦検犖朽犖園硯犢犖ム犢犖÷犖犢犖橿犢犖迦犖巌犖犖犖ム弦犖犖犖犖 5 犖ム弦犖 犢犖犢犖犖迦犖ム犖犖朽犖犢犖犖∇犖朽犖犖伍犢犖ム鍵犖÷顕犖 犖犖朽犖犖伍犖犖朽犖犖巌犖犖犖犖伍犖犖犖 犖犖萎犖橿賢犖∇犖迦犢犖 !!!
  • 10. MAX = MIN = 3 犖犢犖迦検犖朽犖園硯犢犖ム犢犖÷犖犢犖橿犢犖迦犖巌犖犖犖ム弦犖犖犖犖 5 犖ム弦犖 犢犖犢犖犖迦犖ム犖犖朽犖犢犖犖∇犖朽犖犖伍犢犖ム鍵犖÷顕犖 犖犖朽犖犖伍犖犖朽犖犖巌犖犖犖犖伍犖犖犖 犖犖萎犖橿賢犖∇犖迦犢犖 !!!
  • 11. MAX = MIN = 4 犖犢犖迦検犖朽犖園硯犢犖ム犢犖÷犖犢犖橿犢犖迦犖巌犖犖犖ム弦犖犖犖犖 5 犖ム弦犖 犢犖犢犖犖迦犖ム犖犖朽犖犢犖犖∇犖朽犖犖伍犢犖ム鍵犖÷顕犖 犖犖朽犖犖伍犖犖朽犖犖巌犖犖犖犖伍犖犖犖 犖犖萎犖橿賢犖∇犖迦犢犖 !!!
  • 12. MAX = MIN = 5 犖犢犖迦検犖朽犖園硯犢犖ム犢犖÷犖犢犖橿犢犖迦犖巌犖犖犖ム弦犖犖犖犖 5 犖ム弦犖 犢犖犢犖犖迦犖ム犖犖朽犖犢犖犖∇犖朽犖犖伍犢犖ム鍵犖÷顕犖 犖犖朽犖犖伍犖犖朽犖犖巌犖犖犖犖伍犖犖犖 犖犖萎犖橿賢犖∇犖迦犢犖 !!!
  • 13. 犖犖迦牽犢犖犖犖朽権犖犢犖犖朽権犖犖犖園硯犢犖ム 犖犢犖迦牽犖園犖犢犖迦検犖 5 犖犢犖 犢犖犖 n0,n1,n2,n3,n4 犢犖ム犖о見犖迦硯犢犖迦犢犖迦犖犖÷顕犖犖犖朽犖犖伍犖犢犖迦犖 犖犢犖犖∇犖朽犖犖伍 ( 犢犖犖о犖巌犖犖橿賢犖∇犖迦犢犖 ) 犖犖園犖犢犖 cin>>no; cin>>n1;cin>>n2;cin>>n3;cin>>n4 2. 犖犖橿見犖犖犢犖犢 犖犢犖迦犖犖犢犖犢犖 犖犖園硯犖犖朽犖÷顕犖犖犖朽犖犖伍 犢犖ム鍵犖犢犖犖∇犖朽犖犖伍 3. 犢犖犖犖朽権犖犢犖犖朽権犖犖犢犖迦犖園硯犖犖朽犢犖犖ム厳犖犢犖犖∇犖犖巌犖÷犖迦犖犖園硯犖犖朽 2 犢犖犖犖迦鍵犖犖園硯犢犖犖犢犖犢犖÷顕犖犢犖ム鍵犖犢犖犖∇犖朽犖犖伍犢犖犢犖ム犖 4. 犢犖犖犖犖犖ム献犖園犖犢
  • 14. #include<iostream.h> void main(){ int n0,n1,n2,n3,n4; int max,min; cout<<&quot;Enter 5 numbers >> &quot;; cin>>n0;cin>>n1;cin>>n2;cin>>n3;cin>>n4; max = n0;min =n0; //round 1 if (n1>max) max=n1; if (n1<min) min=n1; //round 2 if (n2>max) max=n2; if (n2<min) min=n2; //round 3 if (n3>max) max=n3; if (n3<min) min=n3; //round 4 if (n4>max) max=n4; if (n4<min) min=n4; // Print output cout<<&quot;minimum number = &quot;<<min<<endl; cout<<&quot;maximum number = &quot;<<max<<endl; }
  • 15. #include<iostream.h> void main(){ int n[5]; int max,min,i; cout<<&quot;==== Enter 5 numbers =====&quot;<<endl; for (i=0;i<5;i++) { cout<<&quot;Emter number &quot;<<i+1<<&quot; >> &quot;;cin>>n[i];//first is n[0] Not n[1]; } max=n[0];min=n[0]; for (i=1;i<5;i++) { if (n[i]>max) max=n[i]; if (n[i]<min) min=n[i]; } // Print output cout<<&quot;minimum number = &quot;<<min<<endl; cout<<&quot;maximum number = &quot;<<max<<endl; }
  • 16. For statement For ( init-expression ; cond-expression ; loop-expression ) #include<iostream.h> void main(){ int n[5]={1,2,3,4,5}; int max,min,i; for(i=1;i<=5;i++){ // i+=2 cout<<&quot;Print i value &quot;<<i<<endl; } }
  • 17. int i; for ( i = 0; i < 5; cout<<i<<endl, i++); int i, j; for ( i = 5, j = 10 ; i + j < 20 ; i++, j++ ) cout<<&quot; i + j = &quot;<< (i+j) <<endl;
  • 18. #include<iostream.h> void main(){ int n[5]={1,2,3,4,5}; int i; for (i=0;i<=4;i++) if (i >0) { cout<<n[i]<<endl; i +=2; cout<<&quot;Hahaha 55555 Joke &quot;<<endl; } else { for(int j=0;j<2;j++) cout<<&quot; I am a rock&quot;<<j<<endl; } cout<<&quot;=======================================&quot;<<endl; }// 犖犖ム献犖園犖犢犖犖朽犢犖犢犖犖劇賢犖犖萎犖
  • 19. 犢仰犖犖朽権犖犖犖橿肩犖園犖 For statement 犢犖犖犖犖犖ム犖園犖犖朽
  • 20. #include<iostream.h> void main(){ int i,j,k; cout<<&quot;Print value from 0 to 10,10 to 0 and -5 to 5 &quot;<<endl; cout<<&quot;i j k&quot;<<endl; cout<<&quot;---------------------&quot;<<endl; for(i=0,j=10,k=-5;i<=10,j>=0,k<=5;i++,j--,k++){ // for(i=0,j=0,k=-5;i<=10;i++,j--,k++){ cout<<i<<&quot;&quot;<<j<<&quot;&quot;<<k; cout<<endl; } cout<<&quot;---------------------&quot;<<endl; }
  • 22. #include<iostream.h> void main(){ //Display Celseius and Fahrenheit float cel,fah; cout<<&quot;Celseius Fahreheit &quot;<<endl; for(cel=0;cel<=100;cel++){ fah = 9*cel/5+32; cout<<&quot; &quot;<<cel<<&quot;&quot;<<fah<<endl; } }
  • 23. while..do and dowhile #include <iostream.h> int main() { int odd = 0, even = 0,time=0, result; /* process 10 students; counter-controlled loop */ cout << &quot;Enter Number 0 - 9 &quot;<<endl; while (time < 10){ cout << &quot;Number &quot;<< ++time<<&quot; >>&quot; ; cin >> result; if (result%2 == 0) even ++; else odd++; } cout<<&quot;Odd = &quot;<<odd<<endl; cout<<&quot;Even = &quot;<<even<<endl; } while do 犖犖園犖犢犖 犖犖橿犖о犢犖犢犖 犖犖園犖犢犖犢 0 9 犖犖巌犖犖橿犖о 犢犖ム犖о見犖迦硯犢犖迦検犖 犖犖園硯犢犖ム犖犖項 犢犖ム鍵 犖犖朽 犖犖朽犖犖橿犖о while do
  • 24. while..do and dowhile #include <iostream.h> int main() { int odd = 0, even = 0,time=0, result; cout << &quot;Enter Number 0 - 9 &quot;<<endl; do{cout << &quot;Number &quot;<< ++time<<&quot; >>&quot; ; cin >> result; if (result%2 == 0) even ++; else odd++; }while(time<10); cout<<&quot;Odd = &quot;<<odd<<endl; cout<<&quot;Even = &quot;<<even<<endl; } do..while 犖犖園犖犢犖 犖犖橿犖о犢犖犢犖 犖犖園犖犢犖犢 0 9 犖犖巌犖犖橿犖о 犢犖ム犖о見犖迦硯犢犖迦検犖 犖犖園硯犢犖ム犖犖項 犢犖ム鍵 犖犖朽 犖犖朽犖犖橿犖о ... dowhile
  • 25. 犖犖迦犢犖 j k l 犖犖犖犖 犖÷元 犢犖ム鍵犢犖÷犖÷元犖犖橿肩犖園犖 break #include <iostream.h> int main() {int j,k,l; j=10;k=1;l=0; do{ if(j+k) cout<<&quot;J1+K1 = &quot;<<j+k<<endl; break; l++; j--; }while(k++<6); cout<<&quot;j = &quot;<<j<<&quot; k = &quot;<<k<<&quot; l = &quot;<<l<<endl; }
  • 26. #include < iostream .h> float power3 (float); void main (void) { int i ; for (i=1; i <=10; i++) cout<< i<< <<power3 ( i ) ); } float power3 (float x ) { return x * x * x ; } 1 8 27 64 125 216 343 512 729 1000 Function
  • 27. 1. 犖犖巌犖迦牽犖犖迦犖犖犢犖犖犖÷犢犖犢犖犖犖朽 #include <iostream . h> void main () { int i, j, n; cout << &quot; Enter N = &quot; ; cin >> n; i = n; while ( i >= 1 ) { j = 1; while ( j < i ) { cout << &quot; &quot; ; j ++ ; } while ( j < = n ) { cout << &quot;*&quot; ; j ++ ; } cout << &quot; &quot; ; i--; } } #include <iostream . h> void main () { int i, j, n; cout << &quot; Enter N = &quot; ; cin >> n; for ( i = n;i> = 1;i --) { for ( j = 1;j<i;j ++) cout << &quot; &quot; ; for ( j = i;j< = n;j ++) cout << &quot;*&quot; ; cout << &quot; &quot; ; } } 犢犖犖犖朽権犖犢犖犖朽権犖 犖犖迦牽犢犖犢 While 犢犖ム鍵 For loop
  • 28. #include<iostream> using namespace std; int main() { char *buffer = &quot;Any character stream&quot;; int capa, lettera, nota; char c; capa = lettera = nota = 0; cout<<&quot;Any character stream&quot;; while ( c = *buffer++ ) // Walks buffer until NULL { switch ( c ) { case 'A': capa++; break; case 'a': lettera++; break; default: nota++; } } cout<<&quot;Uppercase a: &quot;<<capa<<&quot;Lowercase a: &quot;<<lettera<<&quot;Not character a: &quot;<<nota; cout<<&quot;Total:&quot;; cout<<(capa + lettera + nota)<<endl; } 犢犖犢犖犖園犖犖朽犖犖迦犖犖朽権犖犢犖犢犖犢犖犖犢犖犖犖÷犖ム犖о犖橿犖迦牽犖犖園犖о犖迦犖犢犖犢犖迦賢犖萎犖 犢犖ム犖о犖犖犖犖橿犖迦検犖о犖 犢犖犖犢犖犖犖÷犖朽犖犖橿犖迦犖犖∇犖迦犢犖犢犖犖朽権犖犖犖謹犖犖÷顕犢犖犖劇犖犖犖萎犖

Editor's Notes

  1. Break = j=10 , k=1, l=0 No break j=4 , k=7, l=6