C-Control Structure Question and Answer
C-Control Structure Question and Answer
41. Find the output
void main ( )
{
int i=1;
if (i<=5)
{
printf("%d", i);
if (i==3)
continue;
i++;
}
}
void main ( )
{
int i=1;
if (i<=5)
{
printf("%d", i);
if (i==3)
continue;
i++;
}
}
- 1
- 123333....
- 12345
- None of these
42. Find the output
void main ( )
{
if (true && false)
printf("TRUE");
else
printf("FALSE");
}
void main ( )
{
if (true && false)
printf("TRUE");
else
printf("FALSE");
}
- FALSE
- TRUE
- Compilation error
- Garbage value
43. Find the output.
void main ( )
{
int x=5;
if (x<4);
{
printf("%d", x++);
printf ("5d", x*=2);
}
else
printf("do it again");
}
void main ( )
{
int x=5;
if (x<4);
{
printf("%d", x++);
printf ("5d", x*=2);
}
else
printf("do it again");
}
- 512
- do it again
- 512do it again
- Compilation error
44. Find the output
void main ( )
{
int x=1;
if ("%d=hallo", x);
}
void main ( )
{
int x=1;
if ("%d=hallo", x);
}
- 1=hallo
- hallo5
- 1
- No output
45. If there are more than one sdtatements present in a 'if' expression then order of evaluation is
- Right to left
- Left to right
- Right-left
- None of these
46. Find the output
void main ( )
{
int i=100, j=100, k=-100;
if (!i>=k)
j+=j;
k+=kl
printf("%d %d %d", i,j, k);
}
void main ( )
{
int i=100, j=100, k=-100;
if (!i>=k)
j+=j;
k+=kl
printf("%d %d %d", i,j, k);
}
- 100 100 0
- 0 100 -200
- 100 200 -200
- 0 200 -100
47. Find the output
void main ( )
{
int a=2, b=0, c=-2;
if (b, a, c)
printf("Lack of C knowledge");
else
printf("Begineer");
}
void main ( )
{
int a=2, b=0, c=-2;
if (b, a, c)
printf("Lack of C knowledge");
else
printf("Begineer");
}
- Lack of C knowledge
- Beginner
- Compilation error
- Runtime error
48. what happens when 'break' statement is omitted from a particular case ?
- Leads to a logical error
- Causes execution to terminate after that case
- Causes execution to continue all subsequent cases
- Causes execution to branch to the statement after the switch statement
49. Find the output
void main ( )
{
int x=5;
if (x=0)
printf("%d", x);
printf('%d, ++x);
}
void main ( )
{
int x=5;
if (x=0)
printf("%d", x);
printf('%d, ++x);
}
- 5 6
- 0 1
- 1
- 6
50. The 'continue' statement is used to
- Continue the next iteration of a loop construct
- Exit the block where it exists and continue after
- Exit the outermost block even if it occurs inside the innermost
- Continue the compilation even an error occurs in a program