This set of C Multiple Choice Questions & Answers (MCQs) focuses on “While Loops – 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()
{
while ()
printf("In while loop ");
printf("After loop\n");
}
a) In while loop after loop
b) After loop
c) Compile time error
d) Infinite loop
View Answer
Explanation: None.
2. What will be the output of the following C code?
#include <stdio.h>
int main()
{
do
printf("In while loop ");
while (0);
printf("After loop\n");
}
a) In while loop
b) In while loop After loop
c) After loop
d) Infinite loop
View Answer
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 0;
do {
i++;
printf("In while loop\n");
} while (i < 3);
}
a)
In while loop In while loop In while loop
b)
In while loop In while loop
c) Depends on the compiler
d) Compile time error
View Answer
Explanation: None.
4. How many times i value is checked in the following C code?
#include <stdio.h>
int main()
{
int i = 0;
do {
i++;
printf("in while loop\n");
} while (i < 3);
}
a) 2
b) 3
c) 4
d) 1
View Answer
Explanation: None.
5. How many times i value is checked in the following C code?
#include <stdio.h>
int main()
{
int i = 0;
while (i < 3)
i++;
printf("In while loop\n");
}
a) 2
b) 3
c) 4
d) 1
View Answer
Explanation: None.
6. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int i = 2;
do
{
printf("Hi");
} while (i < 2)
}
a) Compile time error
b) Hi Hi
c) Hi
d) Varies
View Answer
Explanation: None.
7. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int i = 0;
while (++i)
{
printf("H");
}
}
a) H
b) H is printed infinite times
c) Compile time error
d) Varies
View Answer
Explanation: None.
8. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int i = 0;
do
{
printf("Hello");
} while (i != 0);
}
a) Nothing
b) H is printed infinite times
c) Hello
d) Run time 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 Computer Science Internship
- Buy Computer Science Books
- Watch Advanced C Programming Videos
- Buy C Books