C-Control Structure Question and Answer
C-Control Structure Question and Answer
61. Find the output
void main ( )
{
int a,b,c=4;
if (a=c%2)
b=5;
printf("%d", b);
}
void main ( )
{
int a,b,c=4;
if (a=c%2)
b=5;
printf("%d", b);
}
- 5
- 0
- No output
- Garbage value
62. Find the output
void main ( )
{
char a='A';
if ((a=='z') | | ((a='L') &&
(sizeof (a='\0'))))
a=a;
printf("%c", a);
printf("Nothing");
}
void main ( )
{
char a='A';
if ((a=='z') | | ((a='L') &&
(sizeof (a='\0'))))
a=a;
printf("%c", a);
printf("Nothing");
}
- A Nothing
- Nothing
- L Nothing
- Z Nothing
63. switch statement only tests for
- Relational expression
- Logical expression
- Equality
- All the above
64. Find the output.
voidmain ( )
{
int x=1;
if (x++>=x)
printf("%d",x);
else
printf("%d", ++x)
}
voidmain ( )
{
int x=1;
if (x++>=x)
printf("%d",x);
else
printf("%d", ++x)
}
- 2
- 3
- Compilation error
- None of these
65. Find the output
void main ( )
{
int i, j;
for (i=1, j=5; i++, j--;)
{
if (i==j)
continue;
printf("%d", i);
}
}
void main ( )
{
int i, j;
for (i=1, j=5; i++, j--;)
{
if (i==j)
continue;
printf("%d", i);
}
}
- 2 4 5 6
- 1 2 4 5
- Compilation error
- None of these
66. Which is true about break statement?
- break can make early exit from the block where it appears.
- break can't be used in 'if' construct
- Both a and b
- None of these
67. Find the output
void main ( )
{
char c='\b';
if (c==8)
printf("true");
else
printf("false");
}
void main ( )
{
char c='\b';
if (c==8)
printf("true");
else
printf("false");
}
- true
- false
- Compilation error
- No output
68. Find the output
void main ( )
{
char ch;
if("printf(")")
printf("ok");
else
printf("Bye");
}
void main ( )
{
char ch;
if("printf(")")
printf("ok");
else
printf("Bye");
}
- Ok
- Bye
- 0Ok
- 0Bye
69. Find the output
void main ( )
int x=1, y=3, z=0;
if (x!=y>=z)
printf("Right");
else
printf("Wrong");
}
void main ( )
int x=1, y=3, z=0;
if (x!=y>=z)
printf("Right");
else
printf("Wrong");
}
- Right
- Wrong
- compilation error
- None of these
70. Find the output
void main ( )
{
int a=4, b=8, c=3;
if (a+b!c)
printf("True");
else
printf("False");
}
void main ( )
{
int a=4, b=8, c=3;
if (a+b!c)
printf("True");
else
printf("False");
}
- True
- False
- Compilation error
- None of these