VKV SirTest Lab

For Loops: viva questions and MCQs

Computer Programming Lab (C), Unit 5. 100+ For Loops questions with explanations (Computer Programming Lab (C)). Topics: C For Output, C For. Take a free test now.

Topics

Key terms: line shows, printf, loop tests, program reports, tests divisors, prints, pattern program, header executed, nested loops, expression, controls, update

Sample questions with answers

  1. for (int i = 1; i <= 10; i++) printf("%d x %d = %d\n", 12, i, 12*i); The 4th line shows the product:

    Options: A) 36   B) 48   C) 16   D) 60

    Answer: B) 48. Multiplication table.

  2. In C for loops, "Loop variable scope" means:

    Options: A) A lone semicolon that acts as a loop body   B) for (int i …) keeps i visible only inside the loop in C99   C) Loop that controls columns in a pattern program   D) Loop that runs a known number of times

    Answer: B) for (int i …) keeps i visible only inside the loop in C99. Loop variable scope: for (int i …) keeps i visible only inside the loop in C99.

  3. How many times does for (i = 5; i < 12; i++) execute its body?

    Options: A) 8   B) 6   C) 12   D) 7

    Answer: D) 7. Runs for i = a … b−1.

Take a free For Loops test

All units of Computer Programming Lab (C)