Ask Question
13 April, 16:13

Write an algorithm that receives three numbers from the user and prints out the maximum of the three.

+4
Answers (1)
  1. 13 April, 16:21
    0
    Algorithm:

    1. Create three variables a, b, c.

    2. Read the value of a, b, c from user.

    3. Find maximum of a & b and assign it to m.

    4. Then find maximum of c & m and assign to maxx.

    5. Print maxx.

    Implementation In C++:

    #include

    using namespace std;

    int main ()

    {

    / / variables

    int a, b, c;

    cout<<"Enter three different numbers:";

    / / read value from user

    cin>>a>>b>>c;

    / / maximum of a & b

    int m = (a < b) ? b : a;

    / / maximum of m and c

    int maxx = (m < c) ? c : m;

    / / print maximum of all three

    cout<<"maximum of three number is:"<
    return 0;

    }

    Output:

    Enter three different numbers:12 4 15

    maximum of three number is:15
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write an algorithm that receives three numbers from the user and prints out the maximum of the three. ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers