I tried several times how to write a algorithm and a pseudo code for a program of finding the largest value among 3 user input integers? . I couldn't make it properly. Can i be helped?
Pseudocode for maximum of 3 integers-
print max(max(first_integer,second_integer),third_integer)
So you have three numbers, x, y, and z. You want the largest one. So here are some rules:
That results in the code:
if (x > y)
if (x > z)
largest = x;
else
largest = z;
else // y >= x
if (y > z)
largest = y;
else
largest = z;
If you have a max function that returns the maximum of two numbers, then you can simplify that code:
largest = max(x, y);
largest = max(largest, z);
Which can further be optimized to largest = max(max(x, y), z);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With