A Program to Find the Largest Number

In this example, we are giving a program to find the largest number among the given three numbers.


Program to find the largest number among the given three numbers:

  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. double n1, n2, n3;
  6. cout << "Enter three numbers: ";
  7. cin >> n1 >> n2 >> n3;
  8. if( n1>=n2 && n1>=n3 )
  9. cout << n1 << "is the largest number.";
  10. if( n2>=n1 && n2>=n3 )
  11. cout << n2 << "is the largest number.";
  12. if( n3>=n1 && n3>=n2 )
  13. cout<< n3 << "is the largest number.";
  14. return 0;
  15. }

Output:

Enter three numbers: 17.3
-25.9
14.7
17.3 is the largest number.