write
Programs that read two numbers and
Print the largest number
Answers
Answered by
0
Program to find the greatest of two numbers and greatest of three numbers is discussed here. Input two or integers from the user and find the greatest number among them.
Input & Output format:
Input consists of 2 integers.
Sample Input and Output :
7
9
5
9 is greater.
Algorithm to find the greatest of two numbers and greatest of three numbers
Greatest_of_two_numbers(num1, num2):
If (num1 > num2)
Print num1
Else, print num2
Greatest_of_three_numbers(num1,num2):
If (num1 > num2) and (num1 > num3)
Print num1
Else if (num2 > num1) and (num 2 > num3)
Print num2.
Else, print num3
Input & Output format:
Input consists of 2 integers.
Sample Input and Output :
7
9
5
9 is greater.
Algorithm to find the greatest of two numbers and greatest of three numbers
Greatest_of_two_numbers(num1, num2):
If (num1 > num2)
Print num1
Else, print num2
Greatest_of_three_numbers(num1,num2):
If (num1 > num2) and (num1 > num3)
Print num1
Else if (num2 > num1) and (num 2 > num3)
Print num2.
Else, print num3
Similar questions