VKV SirTest Lab

While and Do-While Loops: viva questions and MCQs

Computer Programming Lab (C), Unit 4. 100+ While and Do-While Loops questions with explanations (Computer Programming Lab (C)). Topics: C While, C While Output. Take a free test now.

Topics

Key terms: condition, controlled loop, entry controlled, least once, loop executes, loops loop, prints, printf, digit numbers, digits equals, program reverses, armstrong

Sample questions with answers

  1. int i = 1, c = 0; while (i <= 20) { c++; i += 2; } printf("%d", c); prints:

    Options: A) 10   B) 20   C) 11   D) 10.5

    Answer: A) 10. i takes 1, 3, 5, … up to n.

  2. int i = 1, c = 0; while (i <= 5) { c++; i += 2; } printf("%d", c); prints:

    Options: A) 4   B) 3   C) 5   D) 2

    Answer: B) 3. i takes 1, 3, 5, … up to n.

  3. In C loops, "while loop" means:

    Options: A) Entry-controlled loop that checks the condition before each iteration   B) One execution of the loop body   C) Statement that skips the rest of the body and goes to the next iteration   D) Variable that counts iterations

    Answer: A) Entry-controlled loop that checks the condition before each iteration. while loop: Entry-controlled loop that checks the condition before each iteration.

Take a free While and Do-While Loops test

All units of Computer Programming Lab (C)