Menu
Question Index
...

What will be the output of the following program?

class WhileExample
{
    public static void main(String s[])
    {
        int n = 0;
        int sum = 0;

        int count = 10;

        while( n <= 6 )
        {
            sum += n;

            if( count < 7 )
            {
                break;
            }
            count--;
        }

        System.out.println("sum = " + sum);
    }
}


sum = 0
sum = 10
Goes into infinite loop
None of the answers

Doubts

Problems

Topic: Using Break In for Loop To Exit

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App