FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 11   



Following program shows you how to find largest number from given 3 numbers.
In this program we get inputs from user and shows largest number from given three numbers using if condition

var input1 = parseInt(prompt("Enter first number:"));
var input2 = parseInt(prompt("Enter second number:"));
var input3 = parseInt(prompt("Enter third number:"));
if ((input1 == input2) && (input1 == input3)) {
    console.log("All numbers are equal");
} else if ((input1 > input2) && (input1 > input3)) {
    console.log(input1 + " is larger than " + input2 + " and " + input3);
} else if ((input2 > input1) && (input2 > input3)) {
    console.log(input2 + " is larger than " + input1 + " and " + input3);
} else if ((input3 > input1) && (input3 > input2)) {
    console.log(input3 + " is  larger than " + input2 + " and " + input1);
}

Output:

Example1:

Enter three numbers:
60
30
10
60 is larger than 30 and 10

Example2:

Enter three numbers:
20
20
20
All numbers are equal



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News