Please disable your adblock and script blockers to view this page
 

Find greatest of three numbers using nested if else in C++ Language

Introduction: In previous articles i explained How to find greatest of three numbers using multiple if statement and What is For loop in C++ Language? Example program to print counting up to given limit and What is goto statement,its advantages and disadvantages with program example and Get number of days in month,year using nested if and Program to check for vowel or consonant using switch case and Swap two numbers without using temporary variable and Check whether a number is positive or negative using if else and Check whether a number is even or odd using if else and  many other C++ programs. Now in this article i have written a program to find/get greatest/largest of three numbers using nested if else in C++ Language.

Implementation: Let's create a program to get largest of 3 numbers.

#include<conio.h>
#include<iostream.h>
main()
{
      int a,b,c;
      cout<<"Enter first number: ";
      cin>>a;
      cout<<"Enter second number: ";
      cin>>b;
      cout<<"Enter third number: ";
      cin>>c;   
      
            if(a>b)
            {
                     if(a>c)
                     {
                      cout<<a<<"  is biggest number";
                     }
                      else
                     {
                        cout<<c<<"  is biggest number";
                     }
           }       
      else
      {
                     if(b>c)
                     {
                     cout<<b<<"  is biggest number";
                     }
                     else
                     {
                     cout<<c<<"  is biggest number";
                     }
      }
       getch();
      }

  • Now run the program using Ctrl+F9
Output:
  Enter first number: 89
  Enter second number: 90
  Enter third number: 6
  90 is biggest number

Now over to you:
"If you like my work; you can appreciate by leaving your comments, hitting Facebook like button, following on Google+, Twitter, Linked in and Pinterest, stumbling my posts on stumble upon and subscribing for receiving free updates directly to your inbox . Stay tuned and stay connected for more technical updates."
Previous
Next Post »

2 comments

Click here for comments
Anonymous
admin
August 11, 2013 ×

thanx.... ! its a simple program,,, but from last 5 hours ,, i am getting confused.. it helped me a lot :) thanxxxx again :) !/\!

Reply
avatar
August 12, 2013 ×

i am very glad to hear that it helped you..thanks for the appreciation.Stay tuned for more updates..

Reply
avatar

If you have any question about any post, Feel free to ask.You can simply drop a comment below post or contact via Contact Us form. Your feedback and suggestions will be highly appreciated. Also try to leave comments from your account not from the anonymous account so that i can respond to you easily.. ConversionConversion EmoticonEmoticon