Thursday, January 17, 2019

C Program To Print Greatest Number Among Three Numbers


Greatest number among three numbers:-

In this C program we will print greatest one number among three numbers from user input value. Here we take three int type variables, name as num1, num2, num3  for input first ,second and third number.

   /*
      Program : Greatest Number Among  Three Numbers
      Filename : greatestNumberThree.c
      IDE Used To Developed : CodeBlocks
      Developed By : Pavito Golui
   */
  #include<stdio.h>
  int main()
   {
       int num1,num2,num3;
       printf("Enter the first number :");
       scanf("%d",&num1);
       printf("Enter the second number :");
       scanf("%d",&num2);
       printf("Enter the third number :");                       
       scanf("%d",&num3);
          if(num1>num2 && num1>num3)
             {
                  printf("First number is greater than second and third number");
             }
           else if(num2>num3)
             {               
                  printf("Second number is greater than first and third number");
            
           else
             {
                printf("Third number is greater than first and second number");
             }  
       return 0;
   } 

Output :

  Program run first time:-
 
  Enter the first number :7
  Enter the second number :16
  Enter the second number :18
  Third number is greater than first and  second number
 
  Program run second time:-
 
  Enter the first number :30
  Enter the second number :20
  Enter the second number :15
  First number is greater than second and third number





0 comments:

Welcome to you in All Coding Help