C++ Program To Find Greater Number Among Given Three Numbers

Let’s start the tutorial to start the discussion to clarify the concept about “C++ Program To Find Greater Number Among Given Three Numbers“. Below, We can see the possibilities to do this task using this tutorial.

C++ Program To Find Greater Number Among Given Three Numbers

C++ Program To Find Greater Number Among Given Three Numbers

Source Code

#include<iostream>
using namespace std;
int main()
{
   /* Program By Ghanendra Yadav
   Visit http://www.programmingwithbasics.com/
   */
   double num1, num2, num3;

    cout<<"Enter Three Numbers: n";
    cin>>num1>>num2>>num3;

   if (num1 > num2 && num1 > num3)
      cout<<"nGreatest Number Is :"<<num1;

   else if (num2 > num3 && num2 > num1)
      cout<<"nGreatest Number Is :"<<num2;

   else if (num1 > num1 && num3 > num2)
      cout<<"nGreatest Number Is :"<<num1;
      
   else if ((num1==num2) && (num2==num3) && (num3==num1))
     cout<<"nAll Are Equal"; 
   

}

Method 2:-

#include<iostream>
using namespace std;
int main()
{
 /* Program By Ghanendra Yadav
   Visit http://www.programmingwithbasics.com/
   */
    double num1, num2, num3;

    cout<<"Enter Three Numbers: ";
    cin>>num1>>num2>>num3;

    if (num1>=num2)
    {
        if(num1>=num3)
            cout<<num1<<" Is The Largest Number. ";
        else
            cout<<num3<<" Is The Largest Number. ";
    }
    else
    {
        if(num2>=num3)
            cout<<num2<<" Is The Largest Number. ";
        else
            cout<<num3<<" is the largest number.";
    }
    
    return 0;

}

Conclusion

We hope you have gained a piece knowledge about “C++ Program To Find Greater Number Among Given Three Numbers“. If you have facing any difficulties during the program execution then contact us via the comment section. Share this tutorial with other C/C++ learners to help them.

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment