Ask Question
14 November, 15:59

How many iterations will loops execute?

(a) for (int i = 0; i < 20; i + + ) { }

(b) for (int i = 1; i < = 20; i + + ) { }

(c) for (int i = 5; i < 20; i + + ) { }

(d) for (int i = 20; i > 0; i - - ) { }

(e) for (int i = 1; i < 20; i = i + 2) { }

(f) for (int i = 1; i < 20; i * = 2) { }

+3
Answers (1)
  1. 14 November, 17:00
    0
    (a) 20

    (b) 20

    (c) 15

    (d) 20

    (e) 10

    (f) 5

    Explanation:

    (a) In this loop it start from "0" and iterated up to the value of i = "19" because there is 1 increment in each iteration i. e (i++) so total iterations will executed 20.

    (b) In this loop it starts from "1" and iterated up to the value of i="20" because there is 1 increment in each iteration i. e (i++) so total iterations will executed 20.

    (c) In this loop it start from "5" and iterated up to the value of i = "19" because their is 1 increment in each iteration i. e (i++) so total iterations will executed 15.

    (d) In this loop, it starts from "20" and iterated up to the value of i = "1" because there is 1 decrement in each iteration i. e (i--) so total iterations will execute 20.

    (e) In this loop, it starts from "1" and iterated up to the value of i="19" because there is 2 increment in each iteration i. e (i=i+2) so total iterations will execute 10.

    (f) In this loop, it starts from "1" and iterated up to the value of i = "19" because there is twice the increment of value of i=i*2 so total iterations will executed 5
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “How many iterations will loops execute? (a) for (int i = 0; i < 20; i + + ) { } (b) for (int i = 1; i < = 20; i + + ) { } (c) for (int i = ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers