-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path07_greater_among_three.c
47 lines (41 loc) · 1.25 KB
/
07_greater_among_three.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// // C program to print greater among three numbers.Print one number of among if two or all are the same
// // Header Files
#include <stdio.h>
#include <conio.h>
// // Main Function Start
int main()
{
float num1, num2, num3;
printf("\nEnter Three Numbers to Check Greater => ");
scanf("%f%f%f", &num1, &num2, &num3);
// // using nested f-else
if (num1 > num2)
{
if (num1 > num3)
printf("\n%f is Greater", num1);
else
printf("\n%f is Greater", num3);
}
else
{
if (num2 > num3)
printf("\n%f is Greater", num2);
else
printf("\n%f is Greater", num3);
}
// // using conditional operator
// // int greater = num1 > num2 ? num1 > num3 ? num1 : num3 : num2 > num3 ? num2
// // : num3;
// // printf("\n%f is Greater", greater);
// // using logical operator and if-else-if ladder
// // if (num1 > num2 && num1 > num3)
// // printf("\n%f is Greater", num1);
// // else if (num2 > num3)
// // printf("\n%f is Greater", num2);
// // else
// // printf("\n%f is Greater", num3);
printf("\n");
getch();
return 0;
}
// // Main Function End