.
2. Input three numbers. Print the highest and lowest of them assuming different numbers are input
Answers
I will be doing it with python:
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')
num3 = input('Enter third number: ')
def greater(no1,no2):
if no1>no2:
return no1
else:
return no2
def greatest(no1,no2,no3):
if greater (no1,no2) > no3:
return greater(no1,no2)
else:
return no3
def lower(no1,no2):
if no1<no2:
return no1
else:
return no2
def lowest(no1,no2,no3):
if lower(no1,no2)<no3:
return lower(no1,no2)
else:
return no3
print(f"Greatest: {greatest(num1,num2,num3)}")
print(f"Lowest: {lowest(num1,num2,num3)}")
Question:-
- WAP to input 3 numbers and print the highest and lowest number.
Program:-
This is written in Python.
a, b, c=int(input()),int(input()),int(input())
print("Largest number is: ",max(a, max(b, c)))
print("Smallest number is: ",min(a, min(b, c)))