Give the output of the following program segment. How many times is the loop executed?

ICSE Class 10 Computer Applications PYQ · 2024 Paper · Section A

2(iv)1 Mark · 2024 · Section A · 2024 Paper

Give the output of the following program segment. How many times is the loop executed?

for(x=10; x>20;x++)

System.out.println(x);

System.out.println(x*2);
Show SolutionHide Solution↓
20

The loop executes 0 times because the loop condition x>20 is false as value of x is 10.

← Previous questionNext question →

Browse the free Computer Applications sample bank