0% found this document useful (0 votes)
40 views4 pages

Assignment-1 Topic-Flow of Control

The document contains multiple questions about analyzing the output and syntax of code snippets using control flow statements like if-else, while, for, do-while, and switch in C++. It asks the reader to determine the output, find syntax errors, count loop iterations, and rewrite loops and conditional statements using different structures.

Uploaded by

Devank Nassa
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views4 pages

Assignment-1 Topic-Flow of Control

The document contains multiple questions about analyzing the output and syntax of code snippets using control flow statements like if-else, while, for, do-while, and switch in C++. It asks the reader to determine the output, find syntax errors, count loop iterations, and rewrite loops and conditional statements using different structures.

Uploaded by

Devank Nassa
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment-1 Topic- Flow of Control

Q Find out the output of the following program #include<iostream.h> void main ( ) { if(2>3>4) cout<<\n Hello word; else cout<<\n Hello word again; } Find out the output of the following program #include<iostream.h> #include<conio.h> void main( ) { while(-3) cout<<Hello word; } Find out the output of the following program #include<iostream.h> void main( ) { while(1) cout<<\n Hello world again; } Find out the output of the following program #include<iostream.h> void main( ) { while(0) cout<<Hello again; } Find out the syntax error(s) in the following program #include<iostream.h> void main( ) { int i=0; while( ) { I = I+1; Cout<<I; } } Find out the syntax error(s) in the following program #include<iostream.h> void main( ) { int i=0; do( ) {

Q.

Q.

I = I+1; Cout<<I; }while( ); } Q Find out the syntax error(s) in the following code #include<iostram.h> void main( ) { char ch=A switch(ch) { int c = 5+4; cout<<c; case A :cout<<\n Value of ch is <<ch; break; case B : cout<<\n Value of ch is <<ch; } } Find out the output of the following #include<iostream.h> void main( ) { for(int I=1,int fact =1;I<=5;I++,fact =fact*I); cout<<fact; }

Find out the syntax error(s) in the following code segment #include<iostream.h> void main( ) { int choice; cin>>choice; switch(choice) { case 1: cout<<choice is 1; break; case 2: cout<<Choice is 2 ;break; case 3: cout<<Choice is 3;break; case 1: cout<<Choice is 1;break; } } Find out the syntax error(s) in the following code segment #include<iostream.h> void main( ) { float choice; cin>>choice; switch(choice) {

case 1.1: case 1.2: case 1.3: default :

cout<<choice is 1; break; cout<<Choice is 2 ;break; cout<<Choice is 3;break; cout<<Wrong choice try again;

} } Find out how many times the following loop will execute i) for(int I=0;I<200;I++) ii) for(int I=0;I<200;I++) { if(I = =175) break; } iii) for(int I=0;I<225;I=I+3)

Rewrite the following for loop segment using while loop i) for(int I=0;I<200;I++) ii) for(int I=0;I<200;I++) { if(I = =175) break; } iii) for(int I=0;I<225;I=I+3) Rewrite the following for loop segment using do - while loop i) for(int I=0;I<200;I++) ii) for(int I=0;I<200;I++) { if(I = =175) break; } iii) for(int I=0;I<225;I=I+3)

Rewrite the following program using switch statement #include<iostream.h> #include<conio.h> void main( ) { int choice; cin>>choice; if(choice = =1 ) cout<<Choice is 1; else if(choice= =2) cout<<Choice is 2; else if(choice = =3) cout<<Choice is 3; else cout<<Wrong Choice. Try again; }

Rewrite the following program using switch statement #include<iostream.h> #include<conio.h> void main( ) { int num,value; cin>>num; if(num = = 5) { value = num*20+25; cout<<Value is :<<value; } else if(num = =10) { value = num*10-15; cout<<value is :<<value; } }

You might also like