Control Structures - Study Mode
[#66] What will be the output of the following C code? #include <stdio.h>
int main()
{
int i = 0
for (
)
printf("In for loop
")
printf("After loop
")
}
Correct Answer
(A) Compile time error
[#67] Which of the following cannot be used as LHS of the expression in for (exp1
exp2
exp3)?
Correct Answer
(D) macros
[#68] What will be the output of the following C code? #include <stdio.h>
int main()
{
int i = 0, j = 0
for (i
i < 2
i++){
for (j = 0
j < 3
j++)
{
printf("1
")
break
}
printf("2
")
}
printf("after loop
")
}
Correct Answer
(C) 1 2 1 2 after loop
[#69] Comment on the output of the following C code. #include <stdio.h>
int main()
{
int a = 1
switch (a)
case 1:
printf("%d", a)
case 2:
printf("%d", a)
case 3:
printf("%d", a)
default:
printf("%d", a)
}
Correct Answer
(D) Compile time error, case label outside switch statement
[#70] What will be the output of the following C code? #include <stdio.h>
int main()
{
int a = 1, b = 1
switch (a)
{
case a*b:
printf("yes ")
case a-b:
printf("no
")
break
}
}
Correct Answer
(C) Compile time error