Menu Close

Greatest of three numbers C++ [FTC]

Greatest of three numbers

Rahul is entering three numbers into the system. He has to find the biggest number from that
inputs. Help rahul to find the biggest number.

Input: Get three integers of positive as well as negative numbers.
Output: Print the greatest integer.

Sample Input :
i0
20
30

Sample Output : 
30
#include <iostream>
using namespace std;
int main()
{
  int x,y,z;
  cin>>x>>y>>z;
  if((x>=y) && (x>=z))
    cout<<x;
  else if((y>=z) && (y>=x))
    cout<<y;
  else
    cout<<z;
  return 0;
}

Input_1:
10
20
30
Output:
30


Input_2:
100
200
100
Output:
200


Input_3:
56
65
23
Output:
65


Illustration of the Output:

Executed using g++ linux