Loop Questions and Answers

Practice Mode
Showing 10 of 98 questions
Q51
Find the output void main ( ) { int i; switch (i) { case 1; printf ('%d", i++); case 2: printf ('%d", i++); case 3: printf('5d", i++); default ; printf ('bye"); } } }
  • A 123456789
  • B 123123123
  • C 123123123bye
  • D 123bye
Answer: Option D
Q52
Find the output void main ( ) { int x=3; while (x--){ int x=10; x--; printc('5d", x); } }
  • A 999999
  • B 999
  • C 2 1 0
  • D 3 2 1
Answer: Option B
Q53
Find the bug in the followig program 1. void main ( ) { 2. while (1) { 3. if (printf('5d', printf("%d', 5))) 4. printf("%d", 3); 5. brak; 6. } 7. }
  • A Line no. 3
  • B Line no. 4
  • C Line no. 5
  • D None of these
Answer: Option D
Q54
Find the output void main ( ) { unsigned int i; for (i=5; i>-1; i--) printf("cite"); }
  • A It will print 'cite' six times
  • B It will print 'cite' infinite times
  • C No output
  • D Compilation error
Answer: Option C
Q55
Find the output #define MAX 10 void main ( ) { int i; for (i=0; i<MAX; i++) { static int count; count+=count; } printf('5d", count); }
  • A 0
  • B 45
  • C 55
  • D Compilation error
Answer: Option D
Q56
Find the output void main ( ) { int x=2 while (++ (x--)==2) printf("MCA"); printf("MBA"); }
  • A MCAMCA.....
  • B MCAMBA
  • C MBA
  • D Compilation error
Answer: Option D
Q57
Find the output void main ( ) { int i; for (i=1; i<=3; i++) { print: printf("C"); printf("%d", i); } }
  • A Error; tag not allowed withing the loop
  • B 1 2 3
  • C C 1 C 2 C 3
  • D Garbage value
Answer: Option C
Q58
Find the output void main ( ) { unsigned char c='0'; while (++c<=255) printf ("%d", c); }
  • A Prints 48 to 255
  • B Prints 1 to 255
  • C Infinite loop
  • D None of these
Answer: Option C
Q59
Find the output void main ( ) char c1; int i=0; c1='a'; while (c>=='a' && c1<='z') { c1++; i++; } printf ('%d", i); }
  • A 25
  • B 26
  • C 123
  • D None of these
Answer: Option B
Q60
Find the output enum (false, true); void main ( ) { int i=1; do { printf ("%d", i); i++; if (i<5) continue; } while (false); }
  • A 123...15
  • B 1
  • C Compilation error
  • D None of these
Answer: Option B
Questions and Answers for Competitive Exams Various Entrance Test