This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Goto & Labels – 1”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. 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);
}
a) 1 4
b) Compilation error
c) 1 2 4
d) 1 3 4
View Answer
Explanation: None.
2. What will be the output of the following C code?
#include <stdio.h>
int main()
{
printf("%d ", 1);
l1:l2:
printf("%d ", 2);
printf("%d\n", 3);
}
a) Compilation error
b) 1 2 3
c) 1 2
d) 1 3
View Answer
Explanation: None.
3. What will be the output of the following 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) Compilation error
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 0, j = 0;
while (i < 2)
{
l1 : i++;
while (j < 3)
{
printf("Loop\n");
goto l1;
}
}
}
a) Loop Loop
b) Compilation error
c) Loop Loop Loop Loop
d) Infinite Loop
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 0, j = 0;
while (l1: i < 2)
{
i++;
while (j < 3)
{
printf("loop\n");
goto l1;
}
}
}
a) loop loop
b) Compilation error
c) loop loop loop loop
d) Infinite loop
View Answer
Explanation: None.
6. 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\n");
goto l1;
}
}
}
a) loop loop
b) compilation error
c) oop loop loop loop
d) infinite loop
View Answer
Explanation: None.
7. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int i = 0;
if (i == 0)
{
goto label;
}
label: printf("Hello");
}
a) Nothing
b) Error
c) Infinite Hello
d) Hello
View Answer
Explanation: None.
8. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int i = 0, k;
if (i == 0)
goto label;
for (k = 0;k < 3; k++)
{
printf("hi\n");
label: k = printf("%03d", i);
}
}
a) 0
b) hi hi hi 0 0 0
c) 0 hi hi hi 0 0 0
d) 0 0 0
View Answer
Explanation: None.
9. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int i = 0, k;
label: printf("%d", i);
if (i == 0)
goto label;
}
a) 0
b) Infinite 0
c) Nothing
d) Error
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Get Free Certificate of Merit in C Programming
- Participate in C Programming Certification Contest
- Become a Top Ranker in C Programming
- Take C Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Practice Computer Science MCQs
- Apply for C Internship
- Practice BCA MCQs
- Buy C Books
- Apply for Computer Science Internship