Menu
Question Index
...

What will be the output of the following program?

public class AddingInLoop {
    public static void main(String[] args) {
        int sum = 10;
        int i = 0;
        while (i <= 5) {
            sum += i;
            i++;
        }
        System.out.println("Sum = " + sum);
    }
}


Sum = 10
Sum = 20
Sum = 25
Compilation Error
Runtime Error

Doubts

Problems

Topic: for Loop Example Program In Java - Sum Of Numbers

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App