Friday, 19 June 2015

C Program to find greatest among four.

Program to find greatest among four numbers.
Program:

#include<stdio.h> 
#include<conio.h>
void main()
{
       float a,b,c,d,n; //Declaring Variable.

       

       printf("Enter the Four Numbers :");  //For printing
       scanf("%f %f %f %f",&a,&b,&c,&d);   //For Input.


         

       n=(a>b && a>c && a>d) ? a: ((b>c && b>d) ? b: ((c>d)?c:d)); 
     
       printf("Greatest Number is : %f",n);  //For printing


       getch();    //Getting a character or waiting for key press

}
Output:


No comments:

Post a Comment