Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Thursday, 12 February 2015

Now in this article we will learn how to find greatest of three numbers using nested if else statement in c language.

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
Categories: ,

0 comments:

Post a Comment