Write an algorithm to find the greatest among two different numbers entered by the user.
Question
Write an algorithm to find the greatest among two different numbers entered by the user.
✨ Free AI Tools for You
Powered by Chatterbot AI
Answer
Here's the algorithm to find the greatest among two different numbers entered by the user:
Algorithm
INPUT
num1
INPUT
num2
IF
num1 > num2
THENPRINT "num1 is greater"
ELSE
PRINT "num2 is greater"
Pseudocode
INPUT num1
INPUT num2
IF num1 > num2 THEN
PRINT "num1 is greater"
ELSE
PRINT "num2 is greater"
Explanation
Step 1 & 2: Take two input numbers from the user.
Step 3: Compare the first number (
num1
) with the second number (num2
).Step 4: Print the result based on the comparison. If
num1
is greater, print "num1 is greater"; otherwise, print "num2 is greater".
India's 1st AI Doubt Solver for CBSE, JEE, and NEET
Ask a Question for Freeand then it's just ₹212 a month