Menu
Question Index
...

What will be the output of the following program?

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

        while( n > 0 )
        {
            n--;
            System.out.println("n = " + n );
        }
    }
}


n = 4
n = 3
n = 2
n = 1
n = 4
n = 3
n = 2
n = 1
n = 0
n = 5
n = 4
n = 3
n = 2
n = 1
n = 0
n = 5
n = 5
n = 5
n = 5
n = 5

Doubts

Problems

Topic: while Loop In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App