Largest among 3 numbers
- Read three integers a, b and c.
- use control structures (if , elif, else) to check the condition.
- if a is greater than b and a is greater than c then print- a is greater value.
- if b is greater than a and b is greater than c then print- b is greater value.
- if c is greater than b and c is greater than a then print- c is greater value.
Least among 3 numbers
- use control structures (if , elif, else) to check the condition.
- if a is smaller than b and a is smaller than c then print- a is smaller value.
- if b is smaller than a and b is smaller than c then print- b is smaller value.
- if c is smaller than b and c is smaller than a then print- c is smaller value.
Input :
a =10
b=20
c=5
Output :
b is greater value
c is least value
Program in python
#program to print largest and least value
a=int(input("enter first num "))
b=int(input("enter second num "))
c=int(input("enter third num "))
# greatest or largest value
if(a>b and a>c):
print("a is greater value")
elif(b>a and b>c):
print("b is greater value")
else:
print("c is greater value")
#smallest or least value
if(a
Output :
enter first num 10
enter second num 20
enter third num 5
b is greater value
c is least value
Comments
Post a Comment
Type Your Comments !
Please do not enter any spam link in the comment box.