Saturday, July 29, 2017

Write a C++ program that prompts the user to input three integer values and find the greatest value of the three values.

/*
For more exercises and lessons, visit http://shegertech.blogspot.com/
*/

#include <cstdlib>
#include <iostream>
#include<iomanip>

using namespace std;

int main()
{
      int a,b,c,max;

     cin>>a>>b>>c;

     max=a; //let max take the first value

   if(max<b) max=b; // compare max with b and update max

   if(max<c) max=c; //compare max with c and take c

   cout<<"Max: "<<max; //output max
 
   system("PAUSE");
   return EXIT_SUCCESS;
}

Share: