how many times are the following loop bodies repeated? What is the final output in each case?
(i) int x = 1;
while (x < 10)
if (x % 2 == 0)
System.out.println(x);
(i)int y = 1;
while (y < 10)
if (y % 2 == 0)
System.out.println(y++);
(i)int z = 1;
while (z < 10)
if ((Z++) % 2 == 0)
System.out.println(z);
Answers
Answered by
9
I) the while loop will be repeated until x equals 10 i.e 9 times.
Final output:
- 2
- 4
- 6
- 8
In every case,loop will repeat 9 times...
Anonymous:
usko kyu pareshan kr rha
Similar questions