Log In Register

Units


While Loops - Questions and Answers

 

Practice these While Loops under C Programming walk-in interview Questions/ examination questions with best tricks and short cuts with solution. Student (candidate) who want to crack the walk in interview, competitive exams and want to find short cuts and tricks to solve questions on While Loops for following purpose.


– Anyone who is wishing to increase their perfect knowledge of While Loops of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically While Loops.
– Anyone who is preparing for interviews (competitive examinations, govt examinations and bank examinations, off-campus or on campus interviews, walk-in interview and company interviews) having questions on While Loops under C Programming.

– Anyone who is preparing for aptitude test or competitive exam or entrance exam.
– Anyone who is preparing for entrance examinations and other competitive examinations.
– All Experienced, Freshers and Students.

Here is list of Questions and Answers covering all key area of  While Loops topic of C Programming:

 

1.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         while ()
  5.             printf("In while loop ");
  6.         printf("After loop\n");
  7.     }

Answer: Option B

Explanation:

2.

How many times i value is checked in the below code?

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

Answer: Option C

Explanation:

3.

What is the output of this C code?

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

Answer: Option B

Explanation:

4.

What is the output of this C code?

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

Answer: Option D

Explanation:

5.

Number of times while loop condition is tested is, i is initialized to 0 in both case.

  1. while (i < n)
  2.          i++;
  3.     ————-
  4.     do
  5.          i++;
  6.     while (i <= n);

Answer: Option C

Explanation:

6.

What is the output of this C code?

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

Answer: Option D

Explanation:

7.

What is the output of this C code?

  1. #include <stdio.h>
  2. void main()
  3. {
  4.     int i = 0;
  5.     while (i < 10)
  6.     {
  7.         i++;
  8.         printf("hi\n");
  9.         while (i < 8) 
  10.         {
  11.             i++;
  12.             printf("hello\n");
  13.         }
  14.     }
  15. }

Answer: Option A

Explanation:

8.

Example of iteration in C.

Answer: Option D

Explanation:

9.

How many times i value is checked in the below code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0;
  5.         while (i < 3)
  6.             i++;
  7.         printf("In while loop\n");
  8.     }

Answer: Option B

Explanation:

10.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         do
  5.             printf("In while loop ");
  6.         while (0);
  7.             printf("After loop\n");
  8.     }

Answer: Option C

Explanation:

11.

Which loop is most suitable to first perform the operation and then test the condition?

Answer: Option A

Explanation:

12.

What is the output of this C code?

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

Answer: Option C

Explanation:

13.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         char *str = "";
  5.         do
  6.         {
  7.             printf("hello");
  8.         } while (str);
  9.     }

Answer: Option A

Explanation:

14.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0, j = 0;
  5.         while (i < 5, j < 10)
  6.         {
  7.             i++;
  8.             j++;
  9.         }
  10.         printf("%d, %d\n", i, j);
  11.     }

Answer: Option D

Explanation:

15.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0;
  5.         while (i = 0)
  6.             printf("True\n");
  7.         printf("False\n");
  8.     }

Answer: Option B

Explanation: