Answer to Question #15267 in AJAX | JavaScript | HTML | PHP for karen fetrow

Question #15267
Convert the following program from for loop to while loop.


class ArithmeticProgression
{
public static void main (String [] args)
{
int sum = 0;


for (int i = 1; i <= 1000; i++)
{
sum = sum + i;
System.out.println(Integer.toString(sum));
}
}
}
1
Expert's answer
2012-09-25T11:47:07-0400
class ArithmeticProgression
{
public static void main (String [] args)
{
int sum = 0;
int i = 1;
while(i <= 1000)
{
sum = sum + i;
System.out.println(Integer.toString(sum));
i++;
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS