Menu
Question Index
...

What will be the output of the following program?

public class FactIs {
    public static void main(String[] args) {
        int number = 6;
        int fact = 1;
        while (number > 1) {
            fact *= number;
            number--;
        }
        System.out.println("Factorial for 6 is " + fact);
    }
}


Factorial for 6 is 1
Factorial for 6 is 120
Factorial for 6 is 720
Compilation Error
Runtime Error

Doubts

Problems

Topic: Factorial Program In Java Using While Loop

Read this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App