Print the MAX number.
Before further discussion, let us solve some examples.
Example
1: Write an algorithm to find the greatest of three numbers and then validate your
algorithm by giving it dry runs.
Solution 1:
The algorithm to find the greatest of three numbers (a, b, and c) is as follows:
Step 1:
Input three numbers from the user: a, b, c.
Step 2:
Check,
if (a > b)
Step 3:
do if (a > c)
Step 4:
then Print ‘a’ and go to step-12.
Step 5:
else
Step 6:
Print ‘c’ and go to step-12.
Step 7:
else
Step 8:
do if (b > c)
Step 9:
then Print ‘b’ and go to step-12.
Step 10:
else
Step 11:
Print ‘c’ and go to step-12.
Step 12:
Stop
Now let us validate this algorithm.
Do'stlaringiz bilan baham: