Program 3
Program to find the largest of three numbers
Aim
Write a program to find the largest of three numbers
Algorithm
[Link]
[Link] first number and store it in variable num1.
[Link] second number and store it in variable num2.
[Link] third number and store it in variable num3.
[Link] the numbers:
[Link] num1 >= num2 and num1 >= num3
→ Print "num1 is the greatest".
[Link] if num2 >= num1 and num2 >= num3
→ Print "num2 is the greatest".
[Link]
→ Print "num3 is the greatest".
9. Stop
Program
num1 = int(input("Enter 1st number: "))
num2 = int(input("Enter 2nd number: "))
num3 = int(input("Enter 3rd number: "))
if (num1 >= num2) and (num1 >= num3):
print(num1, ” is the greatest")
elif (num2 >= num1) and (num2 >= num3):
print(num2, ” is the greatest")
else:
print(num3, “ is the greatest")
Sample Output
Enter 1st number: 6764
Enter 2nd number: 123
Enter 3rd number: 57
6764 is the greatest