Learn Java Programming - Exercise 10x - The While Loop

preview_player
Показать описание

Practice using the while loop in java to control program flow.
Рекомендации по теме
Комментарии
Автор

public class Lesson10Exercise1 {
public static void main(String[] args) {

int num = 1;
int sum = 0;

while(num <= 100){
sum += num++;
}

System.out.println("The sum of all numbers from 1 to 100 = " + sum);
}
}

hendrecarstens
Автор

why you didn't write the print statement in the while loop as u did in the previous video?

maryamabdullah