Use a while loop to calculate the sum of all numbers from 1 to 1000 . Make it print only the sum, not the intermediate values.
How to solve it.
Pls help me any one
Use a while loop to calculate the sum of all numbers from 1 to 1000 . Make it print only the sum, not the intermediate values.
How to solve it.
Pls help me any one
int temp=1000, sum=0;
while (temp>0){sum+=temp; temp–;}
System.out.println("sum: "+sum);