Computer Applications

How many times the for statement given below is executed?

for(k = 10; k >= 0; k--)

  1. 10
  2. 11
  3. 12
  4. 0

Java Iterative Stmts

7 Likes

Answer

11

Reason — The loop starts with k = 10 and runs while k >= 0. This includes both k = 10 and k = 0, so the values of k will be: 10, 9, 8, …, 1, 0 — a total of 11 iterations.

Answered By

4 Likes


Related Questions