Please disable your adblock and script blockers to view this page
 

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

Introduction: In the previous article i explained the program for Else if ladder to perform operation on two numbers based on operator and Find greatest of two numbers using conditional operator and What is For loop in C language? Program to print counting up to given limit and What is goto statement in C language,its advantages and disadvantages with program example and Find greatest of three numbers using multiple if statement and Find week days corresponding to number using switch case. and How to swap two numbers without using temporary variable in C Language? and Check whether a number is positive or negative using if else and Check whether a number is even or odd using if else .
Now in this article i have written a program in C language to Find greatest of three numbers using nested if else statement.

Implementation: Let's create a program to understand better.

#include<conio.h>
#include<stdio.h>
main()
{
      int a,b,c;
      printf("Enter first number: ");
      scanf("%d",&a);
      printf("Enter second number: ");
      scanf("%d",&b);
      printf("Enter third number: ");
      scanf("%d",&c);   
         if(a>b)
            {
                     if(a>c)
                     {
                      printf("%d is biggest number",a);
                     }
                      else
                     {
                        printf("%d is biggest number",c);
                     }
           }       
      else
      {
                     if(b>c)
                     {
                     printf("%d is biggest number",b);
                     }
                     else
                     {
                     printf("%d is biggest number",c); 
                     }
      }
      getch();
      }

  • Now run the program using Ctrl+F9
Output:

Enter first number: 12
Enter second number: 90
Enter third number: 8
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 »

4 comments

Click here for comments
September 25, 2013 ×

what if we want result of five values instead of 3

Reply
avatar
September 26, 2013 ×

Hello Pranav..this is also possible using nested if or some other ways..i will create an article as per your requirement as soon as possible..so keep reading..:)

Reply
avatar
Anonymous
admin
February 14, 2014 ×

it happened to be very helpful for beginner like me.thanxx a lot.....

Reply
avatar
February 14, 2014 ×

thanks for appreciating my work..stay connected and keep reading for more useful updates like this

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