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 = 0; i < 5; i++)
        {
            for (int j = 8; j > 4; j -= 2)
            {
                if (i <= j)
                {
                    out += i + j;
                }
                else
                {
                    out -= j - i;
                }
            }
        }
        System.out.println("out = " + out);
    }
}


out = 155
out = -65
out = 75
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