To find the larger number between three numbers in pseudocode, you can use the following steps:
- Declare three variables
A
,B
, andC
and initialize them with the three numbers. - If
A
is greater thanB
andC
, outputA
as the larger number. - If
B
is greater thanA
andC
, outputB
as the larger number. - If
C
is greater thanA
andB
, outputC
as the larger number. - If
A
andB
are equal and greater thanC
, output eitherA
orB
as the larger number. - If
A
andC
are equal and greater thanB
, output eitherA
orC
as the larger number. - If
B
andC
are equal and greater thanA
, output eitherB
orC
as the larger number. - If all three numbers are equal, output any of the three numbers as the larger number.
Here is the pseudocode that implements these steps:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
Declare A Declare B Declare C If A is greater than B and C output A as the larger number else if B is greater than A and C output B as the larger number else if C is greater than A and B output C as the larger number else if A and B are equal and greater than C output A or B as the larger number else if A and C are equal and greater than B output A or C as the larger number else if B and C are equal and greater than A output B or C as the larger number else output A or B or C as the larger number (since they are all equal) |