Control Structure Questions and Answers

Practice Mode
Showing 10 of 97 questions
Q31
Find the output void main ( ) { enum e{red, green}; enum e ee=red; switch (ee) { case red: printf("red"); break; case green: printf("green"); break; } }
  • A red
  • B Error: constant expression required
  • C green
  • D Enum can't be a part of structure
Answer: Option A
Q32
Find the output void main ( ) { int ch=2; switch (ch++) { case 1: printf("%d", ++ch); case 2: printf("%d", ++ch); default: printf("%d", ++ch); } }
  • A 4
  • B 3
  • C 45
  • D None of these
Answer: Option C
Q33
Find the output void main ( ) int a=2, b=3; do { a=a^b; a=b^a; a=a^b; continue; } while (a==3); printf("%d%d", a, b); }
  • A 2 3
  • B 3 2
  • C Infinite loop
  • D None of these
Answer: Option A
Q34
Find the output void main ( ) { int a=5; while (a!=1) { goto xx; xx: printf("%d", a--); } }
  • A 5
  • B 5 4 3 2 1
  • C 5 4 3 2
  • D Compilation error
Answer: Option C
Q35
Find the output. void main ( ) { int i=5; if (i==5) return; else printf("%d",i); printf("bye"); }
  • A bye
  • B 5
  • C No output
  • D Compilation error
Answer: Option C
Q36
Find the output void main { float f=3.2; switch (f!=3.2) { default: printf("no result"); case 0: printf ("false"); case 1; printf("true"); break; } }
  • A true
  • B no result true
  • C no result false true
  • D Compilation error
Answer: Option A
Q37
'continue'statement is used in
  • A Selective control structure
  • B Loop control structure
  • C Both a and b
  • D None of these
Answer: Option B
Q38
Find the output void main ( ) { float f=2.5; if (f==2.5) printf ("right"); else prrintf ("wrong"); }
  • A right
  • B wrong
  • C Depends on memory model
  • D None of these
Answer: Option A
Q39
Find the output void main ( ) { int i=1, j=2, k=3; if (i==1) if (j==2) if (k==3) { printf("ok"); break } else printf("continue"); printf("bye"); }
  • A ok
  • B okbye
  • C Misplaced break
  • D None of these
Answer: Option C
Q40
Find the output void main ( ) { int i=5; switch (i) { static int i; i=3; i=i*i; case 3: i=i+i; case 5: i=i+i; default : i=i+i; printf("%d", i); } printf ('%d", i); }
  • A 365
  • B 205
  • C 05
  • D 55
Answer: Option C
Questions and Answers for Competitive Exams Various Entrance Test