Menu
Question Index
...

What will be the output of the following program?

public class IsAPerfectNumber
{
    public static void main(String args[])
    {
        int number = 496;
        int sum = 0;
        for (int i = 1; i < number; i++)
        {
            if (number % i == 0)
            sum = sum + i;
        }
        System.out.print((sum == number) ? "Yes" : "No");
    }
}


Yes
No
Compilation Error
Runtime Error

Doubts

Problems

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