2(i)
Rewrite the following program segment using a for loop.
int a = 5, b = 10;
while (b > 0)
{ b -= 2;
}
System.out.println(a * b);Show SolutionHide Solution↓
int a = 5, b = 10;
for( ; b > 0; b -= 2)
{
}
System.out.println(a * b);ICSE Class 10 Computer Applications PYQ · 2026 Paper · Section A
Rewrite the following program segment using a for loop.
int a = 5, b = 10;
while (b > 0)
{ b -= 2;
}
System.out.println(a * b);int a = 5, b = 10;
for( ; b > 0; b -= 2)
{
}
System.out.println(a * b);