64.7k views
2 votes
Write a program that takes in two integers and outputs the larger value.

If the input is: 4 ,2
the output is: 4

User CoreLean
by
8.1k points

1 Answer

5 votes

Final answer:

To write a program that takes in two integers and outputs the larger value, you can use conditional statements in the programming language of your choice.

Step-by-step explanation:

To write a program that takes in two integers and outputs the larger value, you can use conditional statements in the programming language of your choice. Here's an example in Python:



num1 = int(input('Enter the first number: '))
num2 = int(input('Enter the second number: '))

if num1 > num2:
print('The larger value is', num1)
else:
print('The larger value is', num2)



In this code, the two input numbers are compared using an if-else statement. If the first number is greater than the second number, it is printed as the larger value. Otherwise, the second number is printed.

User Aaron J Lang
by
8.9k points