Control Structures - Study Mode
[#81] What will be the output of the following C code? #include <stdio.h>
int main()
{
int *p = NULL
for (foo()
p
p = 0)
printf("In for loop
")
printf("After loop
")
}
Correct Answer
(B) Compile time error
[#82] What will be the output of the following C code? #include <stdio.h>
int main()
{
printf("%d ", 1)
goto l1
printf("%d ", 2)
l1:goto l2
printf("%d ", 3)
l2:printf("%d ", 4)
}
Correct Answer
(A) 1 4
(E) 1 4
[#83] What will be the output of the following C code? #include <stdio.h>
int main()
{
int x = 0
if (x == 1)
if (x == 0)
printf("inside if
")
else
printf("inside else if
")
else
printf("inside else
")
}
Correct Answer
(C) inside else
[#84] What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input) #include <stdio.h>
void main()
{
char *ch
printf("enter a value between 1 to 3:")
scanf("%s", ch)
switch (ch)
{
case "1":
printf("1")
break
case "2":
printf("2")
break
}
}
Correct Answer
(B) Compile time error
[#85] What will be the output of the following C code? #include <stdio.h>
int main()
{
int i = 0, j = 0
l1: while (i < 2)
{
i++
while (j < 3)
{
printf("loop
")
goto l1
}
}
}
Correct Answer
(A) loop loop