Control Structure Questions and Answers

Practice Mode
Showing 10 of 97 questions
Q51
Find the output void main ( ) { int x=100, y=200, z=300, i=300; if (i==z) i=x; else y=y+z; if (i!=z) z=z+x; else y=y+z; printf("5d", y); }
  • A 100
  • B 200
  • C 300
  • D 500
Answer: Option B
Q52
Find the output int i=4; void main ( ) { switch (i) { default: ; case 3: i +=5; if (i==8); { i++; if (i=9); i*=2; } i -=4; break; case 8: i +=5; break; } printf("%d\n", i); }
  • A 5
  • B 16
  • C 18
  • D 14
Answer: Option D
Q53
Find the output void main ( ) { int a=0, b=20; char x=1, y=10; if (x, b--, x--, x++) printf("%d", x); }
  • A 0
  • B 1
  • C 2
  • D None of the above
Answer: Option D
Q54
Find the output void main ( ) { int x=1, y=1, z; if (y<0) if (y>0) x3; else x=5; printf("%d", x); }
  • A 5
  • B 3
  • C 1
  • D Compilation error
Answer: Option C
Q55
Find the output int main ( ) { unsigned val =0Xabcd; if (vval>>16|val<<16) { printf("Success"); } return; printf("Failure"); }
  • A No output
  • B Success
  • C Failure
  • D SuccessFailure
Answer: Option A
Q56
Find the output void main ( ) { int a=1; if (a) printf ("Test"); else; printf("Again"); }
  • A Again
  • B Test
  • C Compilation error
  • D TestAgain
Answer: Option D
Q57
Find the output void main ( ) { static int choice; switch (-- choice, choice -1, choice -1, choice+=2) { case 1: printf("Choice1"); break; case 2: printf("Choice2"); break; default ; printf("Default"); } }
  • A Choice1
  • B Choice2
  • C Default
  • D None of these
Answer: Option A
Q58
Find the output void main ( ) { char ch='r'; if (ch=='a'||ch='h') ch='u'; printf("%c", ch); }
  • A r
  • B a
  • C u
  • D Compilation error
Answer: Option D
Q59
Find the output #define FALSE -1 #define TRUE   1 #define NULL 0 void main ( ) { if (NULL) puts ("NULL"); else if(FALSE) puts ("TRUE"); else { };; puts ("FALSE"); }
  • A TRUE TRUE
  • B TRUE FALSE
  • C FALSE FALSE
  • D FALSE TRUE
Answer: Option B
Q60
Find the output void some_method(int); int i=1; void main ( ) { some_method (i); } some_method(i) { if (i) { printf {If"); some_method (0); } else { printf ("Else"); } }
  • A IfElse
  • B E1self
  • C If
  • D Compilation error
Answer: Option D
Questions and Answers for Competitive Exams Various Entrance Test