Computer Applications

Rewrite the following program segment using a for loop.

int a = 5, b = 10;
while (b > 0)
{ b -= 2;
}
System.out.println(a * b);

Java Iterative Stmts

3 Likes

Answer

int a = 5, b = 10;
for( ; b > 0; b -= 2)
{
}
System.out.println(a * b);

Answered By

2 Likes


Related Questions