algorithm to find maximum of two numbers
September 24, 2022

Algorithm to find Maximum of two numbers

In this tutorial, we are going to write an algorithm to find the maximum of two numbers. using this algorithm we can write a program to find the Maximum of two numbers in most programming languages like C, C++, Python, and Java programming.


Algorithm to find the Maximum of two numbers.

1. Read A and B.
2. If A > B, then
3.   Set MAX:=A.
4. Else:
5.   Set MAX:=B.
6. [End of If structure]
7. Write MAX.
8. Exit

In the above-given algorithm first, we read two numbers A and B. and then we check if A is greater than B then we set the value of A to the MAX variable else we set the value of B to the MAX variable. after that, we write the value of MAX on the output screen and then Exit from the program.

Remember that an algorithm always gives the steps to write a program.

Leave a Reply

Your email address will not be published. Required fields are marked *