C-Loop Question and Answer

C-Loop Question and Answer
71. Find the output
void main ( )
{
int I;
for (I=o; i<20; I++)
{
switch (I)
{
case 0; I +=5;
cse 1 : I +=2;
case 5 : I += 5;
default : I +=4;
}
printf ("%d", I);
}
}

  • 0, 5, 9, 13,13
  • 5, 9, 13, 17,
  • 12, 17, 22,
  • 16, 21,
Show Answer
72. Find the ouptu
void main ( )
{
static int b;
for (;b<5;b++)
{
printf("hello");
main ( );
}
}

  • hello will display 5 times
  • hello will display unknown times
  • Infinite loop
  • Compilation error
Show Answer
73. Find the output
void main ( )
{
char str[20];
static int i;
for (;;)
{
i++[str]='a'+15;
if (i==19)
break;
}
i [str]='\0';
printf ("%s", str);
}


  • P
  • Garbage value
  • Compilation error
  • PPPPPPPPPPPPPPPPPPPP
Show Answer
74. Find the output.
void main ( )
{
unsigned int a=-1;
static int count;
while (a)
{
count++;
a&a-1;
}
prrintf('5d", count);
}

  • 0
  • 1
  • 16
  • None of these
Show Answer
75. Find the output
void main ( )
{
char a[10]={1, 2, 3, 4, 8, 6};
int x;
for (x=0; x<4; x++)
a[x]=x+'a';
printf("%s", a[x]);
}

  • 123456
  • 56
  • 86
  • Garbage
Show Answer
76. Find the output.
void main ( )
{
int i=5, j=2;
do
{
printf('%d", i--);
}
while (j==(float) printf("%d", 12));
}

  • 5
  • 54321
  • Compilation error
  • Infinite loop
Show Answer
77. Find the output.
void main ( )
{
int i=3;
for (i--; i<7; exit (0))
printf("%d", i++);
}

  • No output
  • 2
  • 23456
  • None of these
Show Answer
78. Find the output.
void main ( )
{
int i=9;
for (i--; i--; i--)
printf("%d"", i);
}

  • 9 6 3
  • 7 5 3 1
  • Compiltion error.
  • Infinite Loop
Show Answer
79. Find the output.
void main ( )
{
int i;
for (i=1; i<5; i++)
{
if (i<3)
continue;
else
break;
printf("5d', i);
}
printf('5d", i);
}

  • 23
  • 33
  • 3
  • No output
Show Answer
80. Find the output
void main ( )
{
int a=0;
for (a; ++a; a<=100)
printf('5d',a);
}

  • Print 1 to 100
  • Print 1 to 100 infinite times
  • Print 1 to -32768
  • Infinite loop
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test