Prepare a program that would compute for the sum of the 2 smaller numbers of the 3 numbers entered from custom input.
Enter 3 numbers
Number1: 4
Number2: 5
Number3: 6
The sum of 4 and 5 is 9.
Answers
Answered by
3
The following codes have been written using Python.
#obtaining input
n1 = int(input("Enter a number: "))
n2 = int(input("Enter a second number: "))
n3 = int(input("Enter a third number: "))
#using conditional statements to test conditions
if n1 < n3 and n2 < n3:
print("The smallest numbers are", n1, "and", n2, "and their sum is", str(n1 + n2) + ".")
elif n2 < n1 and n3 < n1:
print("The smallest numbers are", n2, "and", n3, "and their sum is", str(n2 + n3) + ".")
elif n3 < n2 and n1 < n2:
print("The smallest numbers are", n3, "and", n1, "and their sum is", str(n3 + n1) + ".")
Similar questions
Computer Science,
11 days ago
Political Science,
23 days ago
Math,
23 days ago
Math,
8 months ago
Math,
8 months ago
Economy,
8 months ago