Ask Question
26 November, 02:17

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) { }

+5
Answers (1)
  1. 26 November, 05:36
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers