Reputation: 27
This is my first question so I apologize for any errors in advance.
In my algorithm development class we just learned IF ELSE statements, and i've been tasked with writing the pseudocode for a program that will input 3 numbers, decide which two are the largest, and then multiply those two. I've read most answers to questions like these but none of them use only IF ELSE statements, could anyone help me with the pseudocode for this problem?
Upvotes: 2
Views: 5886
Reputation: 344
Multiplying the two largest numbers
Let's assume that we have three integers namely X
, Y
and Z
We are going to read from keyboard the values of those integer
X = INPUT
Y = INPUT
Z = INPUT
The next step is to figure out the two largest number :
There so many approaches for finding the solution to this problem:
if (Y >= X) and (X >= Z)
result = Y * X
else if (Y <= Z) and (Y <= X)
result = X * Z
else
result = Z * Y
the variable result
CONTAIN the multiplication of two largest number.
Upvotes: 3
Reputation: 2930
a =input
b=input
c=input
if a<=b and a<=c:
print b*c
else if b<=c and b<=a:
print a*c
else:
print a*b
Upvotes: -1