(Sort three integers) Write a program that prompts the user to enter three integers and displays them in increasing order.
SOURCE CODE:
# Enter three integers
print("Enter three integers: ")
# Enter the value of a
num1=eval(input())
# Enter the value of b
num2=eval(input())
# Enter the value of c
num3=eval(input())
# Compare the first number with the second and third number
if (num1 >= num2) and (num1 >= num3):
largest = num1
# Compare the second number with the first and third number
elif (num2 >= num1) and (num2 >= num3):
largest = num2
else:
largest = num3
#Compare the first number with the second and third number
if (num1<=num2 and num1<=num3):
smallest = num1
#Compare the second number with the first and third number
elif (num2<=num1 and num2<=num3):
smallest = num2
else:
smallest = num3
# Checking middle number
middle = (num1 + num2 + num3) - largest - smallest
print(largest,middle,smallest)
OUTPUT:
Enter three integers:
2
9
5
9 5 2