Greatest of 3 numbers

Description:

Write a C++ program to get and display the greatest of three numbers Test Case 1 Input (stdin) 10 20 30 Expected Output The greatest number is 30 Test Case 2 Input (stdin) 15 10 5 Expected Output The greatest number is 15

Program :

#include <iostream>

using namespace std;

int main()

{

  float n1 ,n2, n3;

 

  cin >>n1>>n2>>n3;

 

  if(n1>=n2 && n1>=n3)

  {

    cout<<" The greatest number is " << n1;

  }

  if(n2>=n1 && n2>=n3)

  {

    cout<<"The greatest number is " << n2;

  }

  if(n3>=n1 && n3>=n2)

  {

    cout<<"The greatest number is " << n3;

  }

return 0;

}