English

The following is the program segment of a JAVA program: amount = 100 while (i>0) { System.out.println(amount); amount = amount - 1; } Rewrite the above using FOR.

Advertisements

Question

The following is the program segment of a JAVA program:

amount = 100
while (i>0)
{
System.out.println(amount);
amount = amount - 1;
}

Rewrite the above using FOR.

Code Writing
Advertisements

Solution

The given Java program segment, rewritten using a For is:

amount = 100;
for (; i > 0; )
{
    System.out.println(amount);
    amount = amount - 1;
}
shaalaa.com
  Is there an error in this question or solution?
Chapter 7: Statements and their Scope - EXERCISE [Page 164]

APPEARS IN

Dheeraj Mehrotra Computer Science [English] Class 12
Chapter 7 Statements and their Scope
EXERCISE | Q 10. (a) | Page 164
Advertisements
Share
Notifications



      Forgot password?
Use app×