Control Structures - Study Mode
[#131] What will be the output of the following C code? #include <stdio.h>
int main()
{
int x = 1
if (x > 0)
printf("inside if
")
else if (x > 0)
printf("inside elseif
")
}
Correct Answer
(A) inside if
[#132] 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()
{
int ch
printf("enter a value between 1 to 2:")
scanf("%d", &ch)
switch (ch)
{
case 1:
printf("1
")
default:
printf("2
")
}
}
Correct Answer
(C) 1 2
[#133] 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
[#134] 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()
{
double ch
printf("enter a value between 1 to 2:")
scanf("%lf", &ch)
switch (ch)
{
case 1:
printf("1")
break
case 2:
printf("2")
break
}
}
Correct Answer
(A) Compile time error
[#135] What will be the output of the following C code? #include <stdio.h>
int main()
{
if (printf("%d", printf(")))
printf("We are Happy")
else if (printf("1"))
printf("We are Sad")
}
Correct Answer
(D) compile time error