Write an algorithm for the smallest of two numbers
Answers
Answered by
7
We can find the smaller of two numbers a and b using if-else or using ternary operator
1)Using ternary operator
However when a and b are equal then the test condition becomes false and hence the program prints b is smaller than a
2)Using If-Else Statement
Answered by
8
The algorithm for the above problem is as follows:
Explanation:
- Input the first number.
- Input the second number.
- Check, Is the first number is smaller than the second number or not.
- If yes, print the first number.
- If no, Print the second number.
Detailed Explanation:
- The above line refers to the algorithm to find the smallest number if there are two numbers known to the user.
- If any user wants to get profit from the above algorithm, then he needs two numbers which can be solved and get the smallest number after follows the above processor.
- The above line is written in the English language because the step by step processor in the English language written in an algorithm only.
Learn More:
- Algorithm example: brainly.in/question/9781803
- Algorithm: brainly.in/question/1861365
Similar questions