250+ TOP MCQs on While Loops and Answers

online C test on “While Loops”. One shall practice these test questions to improve their C programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These questions can be attempted by anyone focusing on learning C Programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our online C test questions come with detailed explanation of the answers which helps in better understanding of C concepts.

Here is a listing of online C test questions on “While Loops” along with answers, explanations and/or solutions:

1. What will be the output of the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         while ()
  5.             printf("In while loop ");
  6.         printf("After loopn");
  7.     }

a) In while loop after loop
b) After loop
c) Compile time error
d) Infinite loop
Answer: c
Clarification: None.

2. What will be the output of the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         do
  5.             printf("In while loop ");
  6.         while (0);
  7.             printf("After loopn");
  8.     }

a) In while loop
b)

   In while loop
   after loop

c) After loop
d) Infinite loop
Answer: b
Clarification: None.

3. What will be the output of the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int i = 0;
  5.         do {
  6.             i++;
  7.             printf("In while loopn");
  8.         } while (i < 3);
  9.     }

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
Answer: a
Clarification: None.

4. How many times i value is checked in the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int i = 0;
  5.         do {
  6.             i++;
  7.             printf("in while loopn");
  8.         } while (i < 3);
  9.     }

a) 2
b) 3
c) 4
d) 1
Answer: b
Clarification: None.

5. How many times i value is checked in the following C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int i = 0;
  5.         while (i < 3)
  6.             i++;
  7.         printf("In while loopn");
  8.     }

a) 2
b) 3
c) 4
d) 1
Answer: c
Clarification: None.

6. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int i = 2;
  5.         do
  6.         {
  7.             printf("Hi");
  8.         } while (i < 2)
  9.     }

a) Compile time error
b) Hi Hi
c) Hi
d) Varies
Answer: a
Clarification: None.

7. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int i = 0;
  5.         while (++i)
  6.         {
  7.             printf("H");
  8.         }
  9.     }

a) H
b) H is printed infinite times
c) Compile time error
d) Varies
Answer: b
Clarification: None.

8. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int i = 0;
  5.         do
  6.         {
  7.             printf("Hello");
  8.         } while (i != 0);
  9.     }

a) Nothing
b) H is printed infinite times
c) Hello
d) Run time error
Answer: c
Clarification: None.

Leave a Reply

Your email address will not be published. Required fields are marked *