Menu
Question Index
...

What will be the output of the following program?

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


Sum = 10
Sum = 15
Sum = 20
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