Menu
Question Index
...

What will be the output of the following program?

class OutPut
{
    public static void main(String[] args)
    {
        int out = -15;
        for (int i = 5; i < 7; i++)
        {
            for (int j = 8; j >= 6; j--)
            {
                if (i == j) break;
                if (i > j)
                {
                    out += i + j;
                }
                else
                {
                    out += j + i;
                }
            }
        }
        System.out.println("out = " + out);
    }
}


out = -6
out = -78
out = 48
Compilation Error

Doubts

Problems

Topic: Nested for 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