+ All Categories
Home > Documents > CF chap2 engineering fe mcq's

CF chap2 engineering fe mcq's

Date post: 30-Oct-2015
Category:
Upload: cutyverma
View: 502 times
Download: 18 times
Share this document with a friend
Description:
mcq's of 2nd chapter of cf engineering ( fe) of C

of 54

Transcript
  • 1 What would be the output of the following programs?

    #includevoid main( ){int a = 300, b, c ;if ( a >= 400 )b = 300 ;c = 200 ;printf ( "\n%d %d", b, c ) ;getch( );}

    A 300 200

    B Some garbage value and 200 will be printed

    C No output

    D None of the above

    Answer B

    2 What would be the output of the following programs?

    #include

    void main( ){int a = 500, b, c ;if ( a >= 400 )b = 300 ;c = 200 ;printf ( "\n%d %d", b, c ) ;getch( );}

    A 300 200

    B Some garbage value and 200 will be printed

    C No output

    D None of the above

    Answer A

    3. What would be the output of the following programs?

    #include

    void main( ){int x = 10, y = 20 ;if ( x == y ) ;

    printf ( "\n%d %d", x, y ) ;

  • getch( );}

    A Error is present

    B No error but no output

    C 10 20

    D 10 10

    Answer C

    4. What would be the output of the following programs?

    #include

    void main( ){int x = 3, y = 5 ;if ( x == 3 )

    printf ( "\n%d", x ) ;else ;

    printf ( "\n%d", y ) ;getch( );}

    A 3

    B 5

    C error: misplaced else

    D 3 5

    Answer D

    5. What would be the output of the following programs?

    #include

    void main( ){int x = 3 ;float y = 3.0 ;if ( x == y )

    printf ( "\nx and y are equal" ) ;else

    printf ( "\nx and y are not equal" ) ;}

    A x and y are equal

    B x and y are not equal

    C error: float can not be compared with integer value

    D None of the above

  • Answer A

    6. What would be the output of the following programs?

    #include

    void main( ){int x = 3, y, z ;y = x = 10 ;z = x < 10 ;printf ( "\nx = %d y = %d z = %d", x, y, z ) ;getch( );}

    A Error: Lvalue required

    B x=10 y=10 z=0

    C x=10 y=3 z=0

    D x=3 y=10 z=1

    Answer B

    7. What would be the output of the following programs?

    #include

    void main( ){int k = 35 ;printf ( "\n%d %d %d", k == 35, k = 50, k > 40 ) ;getch( );}

    A 35 50 40

    B 1 1 0

    C 0 50 0

    D 1 50 1

    Answer C

    8. What would be the output of the following programs?

    #include

    void main( ){int i = 65 ;char j = A ;if ( i == j )

    printf ( C is WOW ) ;else

  • printf( "C is a headache" ) ;getch( );}

    A C is WOW

    B C is a headache

    C Error: cannot compare int with char

    D None of the above

    Answer A

    9. Point out the errors, if any, in the following programs.#include

    void main( ){float a = 12.25, b = 12.52 ;if ( a = b )printf ( "\na and b are equal" ) ;getch( );}

    A Error: Wrong condition for if

    B No Error, output: a and b are equal

    C No Error, output: a and b are not equal

    D Error: Curly braces missing for if

    Answer B

    10. Point out the errors, if any, in the following programs.

    #include

    void main( ){if ( 'X' < 'x' )

    printf ( "\nascii value of X is smaller than that of x" ) ;getch( );}

    A Error: Wrong condition for if

    B Output: ascii value of X is smaller than that of x

    C No error, no output

    D Error: undefined symbol X

    Answer B

  • 11. What would be the output of the following programs?

    #include

    void main( ){int x = 10 ;if ( x >= 2 ) thenprintf ( "\n%d", x ) ;getch( );}

    A 10

    B No error, no output

    C Error.then can not be used in C

    D 2

    Answer C

    12. What would be the output of the following programs?

    #include

    void main( ){int x = 10, y = 15 ; if ( x % 2 = y % 3 )

    printf ( "\nCarpathians" ) ;getch( );}

    A Error: Lvalue required

    B Output: Carpathians

    C No error, no output

    D None of the above

    Answer A

    13. What would be the output of the following programs?

    #include

    void main( ) {int x = 30 , y = 40 ;if ( x == y )

    printf( "x is equal to y" ) ;elseif ( x > y )

    printf( "x is greater than y" ) ;elseif ( x < y )

    printf( "x is less than y" ) ;

  • getch( );}

    A x is less then y

    B x is equal to y

    C x is greater than y

    D Undefined symbol elseif

    Answer D

    14. What would be the output of the following programs?

    #include

    void main( ){int a, b ;scanf ( "%d %d",a, b ) ;if ( a > b ) ;

    printf ( "This is a game" ) ;else

    printf ( "You have to play it" ) ;}

    A This is a game you have to play it.

    B This is a game

    C You have to play it.

    D Error: Misplaced else

    Answer D

    15. What would be the output of the following programs ?#include

    void main( ){int i = 4, z = 12 ;if ( i = 5 || z > 50 )

    printf ( "\nDean of students affairs" ) ;else

    printf ( "\nDosa" ) ;getch( );}

    A Dean of students affairs

    B Dosa

    C Error

  • D None of the above

    Answer A

    16. What would be the output of the following programs?

    #include

    void main( ){int i = 4, z = 12 ;if ( i = 5 && z > 5 )

    printf ( "\nLet us C" ) ;else

    printf ( "\nWish C was free !" ) ;getch( );}

    A Let us C

    B Error

    C Wish C was free

    D Let us C Wish C was free

    Answer A

    17. What would be the output of the following programs?

    #include

    void main( ){int a = 40 ;if ( a > 40 && a < 45 )printf ( "a is greater than 40 and less than 45" ) ;else

    printf ( "%d", a ) ;getch( );}

    A a is greater than 40 and less than 45

    B 40

    C Both A and C are correct

    D None of the above

    Answer B

    18. What would be the output of the following programs?

    #include

    void main( )

  • {int p = 8, q = 20 ;if ( p == 5 && q > 5 )

    printf ( "\nWhy not C" ) ;else

    printf ( "\nDefinitely C !" ) ;getch( );}

    A Why not C

    B Definitely C

    C Why not C Definitely C

    D None of above

    Answer A

    19. What would be the output of the following programs?

    #include

    void main( ){int i = -1, j = 1, k ,l ;k = i && j ;l = i || j ;printf ( "%d %d", i, j ) ;getch( );}

    A 1 0

    B 1 2

    C 0 1

    D -1 1

    Answer D

    20. What would be the output of the following programs ?#include

    void main( ){int i = -4, j, num ;j = ( num < 0 ? 0 : num * num ) ;printf ( "\n%d", j ) ;getch( );

  • }

    A 0

    B -4

    C Unpredictable

    D None of above

    Answer C

    21. What would be the output of the following programs?

    #include

    void main( ){int k, num = 30 ;k = ( num > 5 ? ( num

  • 23. What would be the output of the following programs?

    #include

    void main( ) { int i=1; while(i

  • #include

    void main( ) { int x=4,y,z; y=--x; z=x--; printf(%d%d%d\n,x,y,z); getch( ); }

    A 2 3 3

    B 3 3 3

    C 4 2 3

    D None of above

    Answer A

    26. What would be the output of the following programs?

    #include

    void main( ) { while(a

  • getch( ); }

    A Error

    B No Output

    C 1 2 3 4 5 6 7 8 9

    D Infinite Loop

    Answer D

    28. What would be the output of the following programs?

    #include

    void main( ) { int x=4,y=0,z; while(x>=0) { x--; y++; if(x= =y) continue; else printf(\n%d%d,x,y); } getch( ); }

    A 4

    B No Output

    C Error

    D 3 1

    13

    0 4-1 5

    Answer D

    29. What would be the output of the following programs?

    #include

    void main( ) { int x=4,y=0,z; while(x>=0)

  • { if(x= =y) break; else printf(%d%d\n,x,y); x--; y++; } getch( ); }

    A Error

    B No Output

    C 4 0

    3 1

    D Infinite Loop

    Answer C

    30. Which follows the case statement?

    A :

    B ;

    C -

    D A newline

    Answer A

    31. What is required to avoid falling through from one case to the next?

    A end;

    B break;

    C Stop;

    D A semicolon.

    Answer B

    32. What keyword covers unhandled possibilities?

    A all

    B contingency

    C default

    D Other

    Answer C

  • 33. What is the result of the following code? int x=0; switch(x) { case 1: printf("One"); case 0: printf("Zero"); case 2: printf("Hello) World"; }

    A One

    B Zero

    C Hello World

    D ZeroHello World

    Answer D

    34. A program stops it's execution when a break statement is encountered?

    A True

    B False

    C

    D

    Answer B

    35. A 'default' case is required in the switch statement?

    A True

    B False

    C

    D

    Answer B

    36. The __________ statement when executed in a switch statement causes immediate exit from the structure.

    A case

    B switch

    C break

    D default

    Answer C

    37. What would be the output of the following programs?

    void main(){ int Number; clrscr();

  • printf("www."); goto x;y: printf("expert");

    goto z;x: printf("cprogramming"); goto y;z: printf(".com"); getch();}

    A www.expertcprogramming.com

    B www.cprogrammingexpert.com

    C www.com

    D none of the above

    Answer B

    38. Assuming that x=2,y=1 and z=0 initially, what will be their values after executing the following code segment

    switch(x){ case 2: x=1; y=x+1; case 1: x=0; break; default: x=1; y=0;}

    A x = 0 and y = 2

    B x = 1 and y = 2

    C x = 1 and y = 0

    D none of the above

    Answer A

    39. Assuming that x=2,y=1 and z=0 initially, what will be their values after executing the following code segment

    switch(y){ case 0: x=0; y=0; case 2: x=2; z=2; break;

  • default: x=1; y=2;}

    A x = 1 and y = 2

    B x = 2 and y = 2

    C x = 0 and y = 0

    D x = 0 and y = 1

    Answer A

    40. What will be the output of following program?

    main(){ int m=0,n=0,p=0; if( m + n + p == 2) goto print;print: printf("m=%d,n=%d,p=%d",m,n,p); }

    A nothing will be printed on the screen

    B m=0,n=0,p=2

    C m=0,n=0,p=0

    D m=2,n=2,p=2

    Answer C

    41. What will be the value of x after executing the following code?

    int x=10,y=15;x=(x==y)?(y+x):(y-x);}

    A 1

    B 0

    C 25

    D 5

    Answer D

    42. What will be output of following segment?

    char ch = 'a';switch (ch){ case 'a': printf("A"); case 'b': printf("B"); default : printf("C");

  • }A A

    B B

    C C

    D ABC

    Answer D

    43. Find which of the following switch related statements has error. Asuming that x and y are of of int type variables and x=1 and y=2

    (Ex1) switch(y);(Ex2) case 10;(Ex3) switch ( x+y )(Ex4) switch (x) {case 2: y = x + y; break;};

    A All statements will raise an error

    B Ex3 and Ex4 are error-free. Ex1 and Ex2 will raise an error

    C Ex1 Ex3 and Ex4 are error-free. Ex2 will raise an error

    D All statements are correct.

    Answer C

    44. Find the output of following code.

    void main(){int choice = 7 ;switch(choice){default :

    printf("nI am in Default");

    case 1 : printf("nI am in case 1"); break;

    case 2 : printf("nI am in case 2"); break;

    case 3 : printf("nI am in case 3"); break;}}

  • A I am in Default n I am in case 1.

    B Error

    C I am in case 3

    D nI am in case 2

    Answer A

    45. What would be the output of the following programs?

    void main()

    {int choice = 1 ;switch(choice){ printf("\nI am in switch");

    case 1 : printf("\nWhat are You Doing in Mumbai"); break;

    case 2 : printf("\nUS is Great Country"); break;

    case 3 : printf("\nWater turns into Gas"); break;}}

    A What are You Doing in Mumbai

    B Error

    C Water turns into Gas

    D US is Great Country

    Answer A

    46. What would be the output of the following programs?

    void main()

    {int choice = 1;int a = 2;switch(choice){

    case 1 :

  • printf("\nC Programming is Very Funny Language"); break;

    case 1 : printf("\n3 Idiots is Funny Movie"); break;

    case a : printf("\nMy name is Pritesh A Taral"); break;}}

    A Variables are not allowed in Case Labels

    B Default is absent

    C No continue statement in Statement

    D All Cases in switch are unique

    Answer A

    47. Is this program is Error free

    void main(){int choice = 2 ;switch(choice){

    case 1 : printf("\nYour Time Starts now"); break;

    case 7-8+3 : printf("\nWhy to Learn C Programming"); break;

    case 9/3 : printf("\nDon't Use Pointer"); break;}}

    A Yes

    B No

    C

    D

  • Answer A

    48. What would be the output of the following programs?

    void main()

    {int choice = 2 ;int Num = 3;switch(choice){

    case 1 : printf("\nSachin Tendulkar is better than any other Cricketer in the World"); break;

    case Num : printf("\nI think , Variable is not allowed in Case"); break;

    case 7-8+3 : printf("\nWhat do you Think ?"); break;}}

    A Error

    B I think , Variable is not allowed in Case

    C What do you Think?

    D Sachin Tendulkar is better than any other Cricketer in the World

    Answer A

    49. What would be the output of the following programs?

    void main()

    {int choice = 2 ;switch(choice);{

    case 1 : printf("\nAllas"); break;

    case 2 : printf("\nBabo"); break;

    case 3 :

  • printf("\nHurray"); break;}printf(" Finally I am in main ");}

    A Error

    B Babo

    C Allas

    D Hurray

    Answer A

    50. What would be the output of the following programs?

    void main(){int choice = 2 ;switch(choice){}

    }Question : Is this program is error free

    A Yes

    B No

    C

    D

    Answer A

    51. What would be the output of the following programs?

    void main()

    {int choice = 2 ;switch(choice){

    case 1 : printf("\nAllas"); break;

    case 2 : printf("\nBabo"); continue;

  • case 3 : printf("\nHurray"); break;}}

    A Babo

    B Error : Misplaced continue

    C Hurray

    D Allas

    Answer B

    52. What would be the output of the following programs?

    void main()

    {int choice = 2 ;switch(choice){

    case 1,2,1 : printf("\nAllas"); break;

    case 1,3,2 : printf("\nBabo"); break;

    case 4,5,3 : printf("\nHurray"); break;}}

    A Babo

    B Error : Multiple Parameter's not allowed

    C Hurray

    D Allas

    Answer A

    53. What would be the output of the following programs?

    void main()

    {

  • int choice = 1 ;switch(choice
  • B Error : Variables are not allowed

    C Hurray

    D Allas

    Answer C

    55. What would be the output of the following programs?

    void main(){int choice = 1 ;switch(choice){case 'A' :case 'a' :

    printf("\nA for Apple"); break;case 'B' :case 'b' :

    printf("\nB for Ball"); break;}}Question : Will this program works

    A Yes

    B No

    C

    D

    Answer A

    56. What would be the output of the following programs?

    void main(){int choice = 2 ;switch(choice){case 1+2/3 :

    printf("\nCase 1"); break;case 2/2*3 :

    printf("\nCase 3"); break;}

    }Question : Does Expressions are allowed in Case Labels

    A Yes

  • B No

    C

    D

    Answer A

    57. What would be the output of the following programs?

    void main(){int choice = -2 ;switch(choice){case -1 :

    printf("\nCase -1"); break;case -2 :

    printf("\nCase -2"); break;}

    }Question : Is it necessary to have Case Labels greater than Zero?

    A Yes

    B No

    C

    D

    Answer B

    58. What would be the output of the following programs?

    void main()

    {int choice = -2 ;switch(choice){case 1 :

    printf("\nCase -1"); break;case '1' :

    printf("\nCase -2"); break;}

    }Question : Is it working properly ?

    A Yes

  • B No

    C

    D

    Answer A

    59. What would be the output of the following programs?

    void main(){int choice = 10 ;switch(choice) {case 10 :

    printf("\nGreater than 10"); break;}

    }Question : Is it working properly?

    A Yes

    B No

    C

    D

    Answer B

    60. What would be the output of the following programs?

    void main()

    { float choice = 10.1 ; switch(choice) { case 10.1 : printf("\nCase 10.1"); break; case 10.2 : printf("\nCase 10.2"); break; case 10.3 : printf("\nCase 10.3"); break;

  • } }Question : Is it working properly ?

    A Yes

    B No

    C

    D

    Answer B

    61. What will the output of the sample code below be?

    int i = 4;switch (i){default: ;case 3:i += 5;if ( i == 8){i++;if (i == 9) break;i *= 2;}i -= 4;break;case 8:i += 5;break;}printf("i = %d\n", i);

    A i=5

    B i=2

    C i=8

    D i=10

    Answer A

    62. what is the output of following?

    #include void main(){ int check=2; switch(check){ case 1: printf("D.W.Steyn"); case 2: printf(" M.G.Johnson");

  • case 3: printf(" Mohammad Asif"); default: printf(" M.Muralidaran"); }}

    A M.G.Johnson

    B M. muralidaran

    C M.G.Johnson Mohammad Asif M.Muralidaran

    D Compilation error

    Answer C

    63. What will be output when you will execute following c code?

    #includevoid main(){ int movie=1; switch(movie20) printf("M.E.K Hussey"); else if(a>30) printf("A.B. de villiers");}

    A M.S. Dhoni

    B A.B. de villiers

  • C M.S Dhoni

    M.E.K HusseyA.B. de Villiers

    D Compilation error: More than oneconditions are true

    Answer A

    65. Within a switch statement

    A Continue can be used but Break cannot be used

    B Continue cannot be used but Break can be used

    C Both Continue and Break can be used

    D Neither Continue nor Break can be used

    Answer B

    66. What will be output when you will execute following c code?

    #include#define L 10void main(){ int money=10; switch(money,money*2){ case L: printf("Willian"); break; case L*2:printf("Warren"); break; case L*3:printf("Carlos"); break; default: printf("Lawrence"); case L*4:printf("Inqvar"); break; } }

    A Willian

    B Warren

    C Lawrence Inqvar

    D Compilation error

    Answer B

    67. What will be output when you will execute following c code?

    #includevoid main(){ int const X=0; switch(5/4/3){

  • case X: printf("Clinton"); break; case X+1:printf("Gandhi"); break; case X+2:printf("Gates"); break; default: printf("Brown"); }}

    A Clinton

    B Gates

    C Compilation Error

    D Gandhi

    Answer C

    68. what is output for below code

    #include int main(void) { int i=1,j=2; switch(i) { case 1: printf("GOOD");break; case j: printf("BAD");break; } return 0; }

    A good

    B bad

    C error

    D no output

    Answer C

    69. Point out the error, if any in the program.

    #includeint main(){ int a = 10; switch(a) { } printf("This is c program."); return 0;

  • }A Error: No case statement specified

    B Error: No default specified

    C No Error

    D Error: infinite loop occurs

    Answer C

    70. Point out the error, if any in the program.

    #includeint main(){ int i = 1; switch(i) { printf("This is c program."); case 1: printf("Case1"); break; case 2: printf("Case2"); break; }return 0;}

    A Error: No default specified

    B Error: Invalid printf statement after switch statement

    C No Error and prints "Case1"

    D None of above

    Answer C

    71. Which of the following errors would be reported by the compiler on compiling the program given below?

    #includeint main(){ int a = 5; switch(a) { case 1: printf("First");

  • case 2: printf("Second");

    case 3 + 2: printf("Third");

    case 5: printf("Final"); break;

    } return 0;}

    A Final

    B No Error, No Output

    C Error is present

    D None of the above

    Answer C

    72. What is the result of the following code?

    int x=0;switch(x){case 1: printf( "One" );case 0: printf( "Zero" );case 2: printf( "Hello World" );}

    A One

    B Zero

    C Hello World

    D ZeroHello World

    Answer D

    73. What will be output of following c code?

    #include

    int main(){

    int x=011,i;

    for(i=0;i

  • continue;

    printf("End");

    }

    return 0;

    }

    A Start

    B start start

    C start start start

    D None of above

    Answer C

    74. The break stmt is frequently used to terminate the processing of a particular case ....

    A Within a switch Stmt

    B outside a case stmt

    C After a switch stmt

    D Before a switch stmt

    Answer A

    75. The goto statement transfers control to a label. The given label must reside in the _____function and can appear before only one statement in the same function.

    A Same

    B Different

    C Inside

    D Outside

    Answer A

    76. When we use the case control structure ?

    A To choose one from multiple alternatives

    B To switch from one instruction to another

    C To make the execution fast

    D None of above

    Answer A

  • 77. The case keyword is followed by ?

    A Float values

    B Character values

    C integer values

    D Both b and c

    Answer D

    78. What will be the output of following ?void main( )

    { int suite =1;

    switch(suite); {

    case 0: printf("Its morning time"); case 1:

    printf("Its evening time"); }

    }

    A Error

    B Its morning time

    C Its evening time

    D None of above

    Answer A

    79. The value that follows the keyword CASE may only be ?

    A Constant

    B Variable

    C Semicolon

    D number

    Answer A

    80. What will be output when you will execute following c code?

    #includevoid main(){ int const X=0; switch(5/4/3){ case X: printf("Clinton"); break; case X+1:printf("Gandhi"); break; case X+2:printf("Gates");

  • break; default: printf("Brown"); }}Choose all that apply:

    A Clinton

    B Compilation error

    C Gandhi

    D Gates

    Answer B

    81. What is the final value of x when the code

    int x; for(x=0; x

  • C iteration

    D All

    Answer D

    85. What will be the output of the following program ?

    Void main (){Char x=d;Swich (x){Case b : puts(0 1 001);Break;Default : puts(1 2 3);Break;Case R : puts (I II III);}}

    A 1 2 3

    B 0 1 001

    C I II III

    D None of the above

    Answer A

    86. The do-while statement lets you repeat a statement or compound statement until aspecified expression becomes:

    A True

    B False

    C

    D

    Answer A

    87. What will be the output of following code ?#includeint main( ){

    int x=10,y=20;if(x = = y) printf("%d%d",x,y);

    return 0;}

  • A Garbage values

    B Raise an error

    C Prints Nothing

    D None of above

    Answer C

    88. Which of the following statement is used to take the control to the beginning of the loop ?

    A exit

    B break

    C continue

    D None of these

    Answer C

    89. A do - while loop is useful when we want that the statement within the loop must be executed ?

    A only once

    B at least once

    C more than once

    D None of above

    Answer B

    90. What would be the output of the following programs?#include

    void main( ){

    int i; for(i=1;i

  • D goto statement

    Answer C

    92. How many times "HELLO" is get printed?

    #includeint main(){ int x; for(x=-1; x

  • C 2 1

    1 2

    D None of these

    Answer B

    94. What will be printed when the sample code is executed?

    int x = 0; for (x=1; x

  • How many times is the phrase "In the loop" printed?

    A 1

    B 2

    C 3

    D 4

    Answer B

    96. What will be output of following c code?

    #includeint main(){ int i=2,j=2; while(i+1?--i:j++) printf("%d",i); return 0;}

    A 2

    B 1

    C 3

    D compiler error

    Answer B

    97. Which of the following is true regarding the continue statement in a for loop?

    A continue transfers the control flow to the initialization statement of the for loop.

    B continue transfers the control flow to the conditional statement of the for loop.

    C continue transfers the control flow to the update statement of the for loop.

    D continue transfers the control flow to the statement just after the for loop

    Answer C

    98. What will be output of following c code?

    #includeint main(){ int i,j; i=j=2,3; while(--i&&j++) printf("%d %d",i,j); return 0;}

    A 2 3

    B 1 3

  • C 1 2

    D 1 1

    Answer B

    99. What will be output of following c code?

    #includeint main(){ for(;;) { printf("%d ",10); } return 0;}

    A 10

    B 0

    C Logical error

    D Infinite loop

    Answer D

    100. What will be the output of the following program?

    Void main (){Char x=H;Clrscr ();Switch(x){Case H: printf(%c, H);Case E: printf(%c, E);Case L: printf(%c, L);Case L: printf(%c, L);Case O: printf(%c,O);}}

    A HELLO

    B HELlo

    C H

    D None of this

    Answer A

    101. What will be the output of the program?

    #includeint main(){

  • unsigned int i = 65535; /* Assume 2 byte integer*/ while(i++ != 0) printf("%d",++i); printf("\n"); return 0;}

    A Infinite loop

    B 0 1 2 ... 65535

    C 0 1 2 ... 32767 - 32766 -32765 -1 0

    D No output

    Answer A

    102 The minimum number of times the while loop is executed is

    A 1

    B 0

    C cannot be predicted

    D Non of the above

    Answer B

    103. The minimum number of times the do while loop is executed is

    A cannot be predicted

    B 1

    C 0

    D 2

    Answer B

    104. A do while loop is useful when we want the statements within the loop must be executed

    A atleast once

    B more than once

    C exactly once

    D none of the above

    Answer A

    105. what is the output for below code

    for(i=1;i!=5;i++){printf("%d",(i+2));}

    A 3 4 5 6

  • B 3 4 5

    C 3 5 7 9 11

    D 1 2 3 4 5

    Answer A

    106. The minimum number of times the for() loop is executed is

    A 1

    B 0

    C cannot be predicted

    D Non of the above

    Answer B

    107. Which of the following declaration of for statement is syntactically correct?

    A for();

    B for(;);

    C for(,)

    D for(;;)

    Answer D

    108. The keyword else can be used with

    A if statement

    B Switch () statement

    C dowhile () statement

    D None of the above

    Answer A

    109. What will be output of following c code?

    #includeint main(){ int i=1; for(i=0;i=-1;i=1) { printf("%d ",i); if(i!=1) break; } return 0;}

    A 1

    B 2

    C 3

  • D 4

    Answer A

    110. What is the output of the following code:

    void main()

    {

    int n;

    for(n=0;n

  • B for(increment counter; initialize counter; test counter)

    C for(test counter; increment counter; initialize counter);

    D for(initialize counter; test counter; increment counter)

    Answer D

    113. What will be output of the following program?

    #includeint main(){ int a=2,b=7,c=10; c = a==b; printf("%d",c); return 0;}

    A 0

    B 1

    C 2

    D 4

    Answer A

    114. What will be output of the following program?

    #includeint main(){ printf("%d %d %d",sizeof(3.14),sizeof(3.14f),sizeof(3.14L)); return 0;}

    A 1 2 4

    B 2 6 8

    C 1 2 3

    D 8 4 10

    Answer D

    115. Point out the error, if any in the while loop.

    #includeint main(){int i=1;while() {printf("%d\n", i++);if(i>10)

  • break; }return0;}

    A There should be a condition in the while loop

    B There should be at least a semicolon in the while

    C The while loop should be replaced with for loop.

    D No error

    Answer A

    Question What will be the output of the program?

    #includeint main(){ int i=0; for(; i

  • D hello world

    Answer C

    118. Which of the following statements are true for the following Program?

    #includevoid main()

    {int x=10, y=100%9;for(i=1;i

  • C run time error

    D a and b are equal

    Answer D

    121. Which of the following statement transfers the control to the beginning of the loop?

    A Exit

    B Break

    C Continue

    D None of the above

    Answer C

    122. The if statement in ` C ` is terminated by

    A {

    B ,

    C :

    D None of the above

    Answer D

    123. The two way selection is implemented using _______ statement.

    A Case

    B switch

    C else---if

    D if-------else

    Answer D

    124. Which of the following data types cannot be written in a switch - case statement?

    A Character

    B Integer

    C Float

    D Enum

    Answer C

    125. In what sequence the initialization, testing and execution of the body is done in a` do-while ` loop

    A initialization, execution of the body, condition testing

    B Execution of the body, initialization, condition testing

    C initialization, condition testing, execution of the body

  • D None of the above

    Answer A

    126. Goto statement is used for _____ .

    A Conditional jump only

    B both conditional and unconditional jumps

    C Unconditional jump only

    D None of the above

    Answer C

    127. The loop condition is tested at the -----------of the ` dowhile ` construct.

    A Start

    B Middle

    C End

    D Start & End

    Answer C

    128. Which of the following is an iterative control structure?

    A Decision Making

    B Sequential

    C Jump

    D Loop

    Answer D

    129. Which of the following statement does not belong to structured programming?

    A while

    B for

    C go-while

    D goto

    Answer D

    130. What is an infinite loop?

    A It is an endless loop

    B It is a nested loop

    C It means multiple loops

    D It is an unclosed loop

    Answer A

  • 131. The condition is tested at the -----------of loop in a ` while ` statement

    A Start

    B Middle

    C End

    D Any Where

    Answer A

    132. A ` switch ` statement is used to make a decision _________________.

    A to switch the processor to execute some other program

    B between two alternatives

    C amongst many alternatives

    D none of these

    Answer C

    133. 'DOWHILE and 'FOR' structure are called

    A Sequential logic structures

    B Iterative logic structures

    C Decision logic structures

    D None of the above

    Answer B

    134. IFELSE or CASE structure are called

    A Selection logic structures

    B Iteration logic structures

    C Sequence logic structures

    D Program logic structures

    Answer A

    135. Which of the following is keyword

    A if

    B String

    C data type

    D None of these

    Answer A

  • 136. The Correct syntax for the ` for ` loop in ` C ` is ________.

    A for(i=1; i

  • Answer B

    139. In the program given below, point out the error, if any, in the ` for ` loop

    #include

    main()

    {

    int i=1;

    for(;;)

    {

    printf(\"%d \", i++);

    if(i>10) break;

    }

    }

    A The condition in the for loop is a must

    B There should be a semicolon after the for loop

    C 12345678910

    D Error

    Answer D

    140. What would be the output of the following programs?

    void main()

    {

    int x;

    double d =1.5;

    switch (d)

    {

    case1.0: x =1;

    case1.5: x =2;

    case2.0: x =

    A The program has a syntax error because the required break statement is missing in the switch statement.

    B The program has a syntax error because the required default case is missing in the switch

  • statement

    C No errors

    D The program has an error because a double variable has been used in the \'switch case\' construct

    Answer D

    141. Which of the following is the correct output for the program given below

    #include

    #include

    void main()

    {

    float a=0.7;

    if(0>a)

    printf("Hi");

    else

    printf("Hello");

    getch();

    }

    A Hi

    B Hi Hello

    C Hello

    D None of the above

    Answer C

    142. Which of the following is not a control statement in C?

    A For

    B do-while

    C while

    D else

    Answer D

    143. When an ` if..else ` statement is included within an ` if ..else ` statement , it is known as a _________.

    A Next if statement

  • B another if statement

    C combined if statement

    D Nested if statement

    Answer D

    144. Which of the following statements is/are correct for the code shown below

    if (n


Recommended