C-Control Structure Question and Answer

C-Control Structure Question and Answer
81. Find the output
void magic (int);
void main ( )
{
int a=100;
magic (a);
}
void magic (int a)
{
if (a!=0)
{
printf ("%c", "abcdefgh" [a%8]);
}
else
printf ("\n");
}

  • 4
  • d
  • bee
  • e
Show Answer
82. Find the output
void main ( )
{
int i=1;
for (i, i++<=3;)
{
switch (i)
{
case 1:
printf("one");
continue;
case 2:
printf ("two");
break;
case 3:
printf ("three");
continue;
}
}
}

  • onetworthree
  • twothree
  • No output
  • Compilation error
Show Answer
83. Find the output
int main (int k)
{
if (k<5)
printf("%d ", main (k+1));
return k;
}

  • 5 4 3 2 1
  • 5 4 3 2
  • 4 3 2 1
  • 4 3 2
Show Answer
84. Find the output
void main ( )
{
int i=1, j=-1;
if ((printf("%d", i))<
(printf("%d", j)))
printf ("%d", i);
else
printf ("%d", j);
}

  • 1 -1 1
  • 1 -1 -1
  • 1
  • -1
Show Answer
85. Find the output
void main ( )
{
int i=12;
if (i==12)
{
i=10;
}
else
{
i=20;
}
printf("%d", i);
}

  • 12
  • 10
  • Garbage value
  • Compilation error.
Show Answer
86. Which of the following is incorrect about a switch statement ?
  • It is not necessary to use a break in every switch statement.
  • Compiler implements a jump table for cases used a switch.
  • Switch is useful to check whether a value falls in different range or not.
  • Switch is useful to check the value of a variable against a particular set of values.
Show Answer
87. Find the output
void main ( )
{
int _if=1, else=5;
if (_if==10);
else (_else==7);
printf ("%d",_else);
}

  • 5
  • 7
  • No output
  • Compilation error
Show Answer
88. Find the output
void main ( )
{
while (1)
{
if (printf("%d", printf ("5d")))
{
printf("Hi");
break;
}
else
printf("HoHo");
}
}

  • 10HoHo
  • 01Hi
  • Garbage value
  • None of these
Show Answer
89. Find the output
void main ( )
{
int x=0, y=0;
if (!x)
{
y=!x;
if (y)
x=!y;
}
printf ("%d %d", x,y);
}


  • 0 0
  • 1 1
  • 0 1
  • 1 0
Show Answer
90. Find the output
void main ( )
{
int i=1;
switch (i)
{
case 1;
switch (i)
printf ("\nFM");
case 1*2+4:
printf("Radio");
}
}

  • FM
  • FMRadio
  • Radio
  • Compilation error
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test