Loop Questions and Answers

Take Exam

Loop Questions with Answers are among the most frequently asked topics in C programming aptitude and placement exams. These programming questions and answers test your understanding of iteration techniques such as for, while, and do-while loops. Practicing C loop MCQs with explanations helps you strengthen your logic-building skills and code efficiency. Commonly featured in Infosys, Accenture, and TCS placement papers, these loop-based problems prepare you for both theoretical and coding assessments. Access free C programming loop questions with answers PDF or take mock tests online for real exam experience.

Loop

Showing 10 of 98 questions

61. Find the outputt void main (int seizeofargv, char *argv[ ]) { while (sizeofargv) printf ('%s', argv[-- sizeof argv]); }

  • Garbage string
  • filename.exe
  • filename.c
  • filename.obj
Show Answer Report

62. Find the output void main ( ) { int x, y=1, z; if (x=z=y); x=3; while (y<4) x+=++y; printf('%d %d\n", x, y); }

  • 3 1
  • 12 4
  • 12 5
  • 3 5
Show Answer Report

63. Find the output int i; void main ( ) { int j; for (j=2; printf("%d', i)-j; printf("%d", j)) printf("%d", j--); }

  • 0210100
  • 0210
  • 021010
  • Compilation error
Show Answer Report

64. Find the output void main ( ) { char as [ ] ="\\00\0"; int i=0; do { switch(as[i++]) { case '\\'; : printf("A"); break; case 0: printf("B"); break; default: printf ("C"); break; } } while (i<3); }

  • ABC
  • ACB
  • CAB
  • CBA
Show Answer Report

65. Find the output void main ( ) { int a=5; for (;a=0 ? !a:a;) printf("Hello"); }

  • Infinite loop
  • Compilation error
  • Hello will be printed only once
  • No output
Show Answer Report

66. Find the output void main ( ) { char str [ ]="ANDAMAN NIKOBAR"; int i, c, A=0, N=0, Extra=0; for (i=0; (c=str [i])! = c; i++) { switch (c) { case 'A' : A++; continue; case 'N" : N++; default : EXTRA++; } } printf("%d", EXTRA); }

  • 10
  • 11
  • 12
  • 13
Show Answer Report

67. Find the output void main ( ) { int p=3; while (p--); { static int i=3; printf("%d", --i); } }

  • 2 1 0
  • 2 2 2
  • Infinite loop
  • 2
Show Answer Report

68. Find the o utput void main ( ) { int x=0; for (;;) { if (x++==4) break; continue; } printf("x = %d", x); }

  • x=0
  • x=4
  • x=5
  • Infinite loop
Show Answer Report

69. Find the output void main ( ) { int i,j; i=1; j=5; for (;++i<--j;) continue; printf('5d %d", i, j); }

  • 3 4
  • 2 4
  • 3 2
  • 3 3
Show Answer Report

70. Find the output void main ( ) { int i=0; for (-i--; ++i; printf('%d", i)); printf("%d", i); }

  • 0
  • Infinite loop
  • 1
  • Compilation error
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test