forked from saurav2401/C_Basics
-
Notifications
You must be signed in to change notification settings - Fork 1
/
greatest_ter.c
27 lines (21 loc) · 913 Bytes
/
greatest_ter.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// This is the program for checking the greatest among 3 number
/* Sample Input :
Enter the number 1 : 16
Enter the number 2 : 8
Enter the number 3 : 18
Sample Output :
18 is greatest
*/
#include <stdio.h>
void main()
{
int num1 , num2 ,num3 ; // variable declaration
printf("Enter the number 1 :");
scanf("%d",&num1); // input number 1
printf("Enter the number 2 :");
scanf("%d",&num2); // input number 2
printf("Enter the number 3 :");
scanf("%d",&num3); // input number 3
// Below line is for checking the greatest among 3 number using ternary operator
(num1 > num2) ? ((num1 > num3) ? (printf("%d is greatest",num1)) : (printf("%d is greatest",num3))) : ((num2 > num3) ? (printf("%d is greatest",num2)) : (printf("%d is greatest",num3))) ;
}