Using while loops

Edit on Github instead

While loops can help perform tasks like summing the numbers between 0 and 50 inclusive:

int i = 0, int sum = 0
while(i < 51){
    sum += i
    i++
}
// At the end for the loop, when i = 51, sum = 1275

Suggest changes

Related links

URL Topic Source