1. What is the output of this C code?
-
#include <stdio.h>
-
void main()
-
{
-
int i = 5, k;
-
if (i == 0)
-
goto label;
-
label: printf("%d", i);
-
printf("Hey");
-
}
a) 5
b) Hey
c) 5 Hey
d) Nothing
Answer
Answer: c [Reason:] None.
2. goto can be used to jump from main to within a function
a) true
b) false
c) depends
d) varies
Answer
Answer: b [Reason:] None.
3. What is the output of this 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);
-
}
a) 1 4
b) Compile time error
c) 1 2 4
d) 1 3 4
Answer
Answer: a [Reason:] None.
4. What is the output of this C code?
-
#include <stdio.h>
-
int main()
-
{
-
printf("%d ", 1);
-
l1:l2:
-
printf("%d ", 2);
-
printf("%dn", 3);
-
}
a) Compile time error
b) 1 2 3
c) 1 2
d) 1 3
Answer
Answer: b [Reason:] None.
5. What is the output of this C code?
-
#include <stdio.h>
-
int main()
-
{
-
printf("%d ", 1);
-
goto l1;
-
printf("%d ", 2);
-
}
-
void foo()
-
{
-
l1: printf("3 ", 3);
-
}
a) 1 2 3
b) 1 3
c) 1 3 2
d) Compile time error
Answer
Answer: d [Reason:] None.
6. What is the output of this C code?
-
#include <stdio.h>
-
int main()
-
{
-
int i = 0, j = 0;
-
while (i < 2)
-
{
-
l1: i++;
-
while (j < 3)
-
{
-
printf("loopn");
-
goto l1;
-
}
-
}
-
}
a) loop loop
b) Compile time error
c) loop loop loop loop
d) Infinite loop
Answer
Answer: d [Reason:] None.
7. What is the output of this C code?
-
#include <stdio.h>
-
int main()
-
{
-
int i = 0, j = 0;
-
while (l1: i < 2)
-
{
-
i++;
-
while (j < 3)
-
{
-
printf("loopn");
-
goto l1;
-
}
-
}
-
}
a) loop loop
b) Compile time error
c) loop loop loop loop
d) Infinite loop
Answer
Answer: b [Reason:] None.
8. What is the output of this C code?
-
#include <stdio.h>
-
int main()
-
{
-
int i = 0, j = 0;
-
l1: while (i < 2)
-
{
-
i++;
-
while (j < 3)
-
{
-
printf("loopn");
-
goto l1;
-
}
-
}
-
}
a) loop loop
b) Compile time error
c) loop loop loop loop
d) Infinite loop
Answer
Answer: a [Reason:] None.