forked from akn714/1st-yr-c-programs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
7.c
35 lines (29 loc) · 691 Bytes
/
7.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
// Task : WAP to find the greatest of three numbers
#include <stdio.h>
int main() {
int a, b, c;
// inputting 3 numbers
scanf("%d %d %d", &a, &b, &c);
// finding the greatest number among the 3
// method 1
if(a>b){
if(a>c){
printf("%d is the greatest\n", a);
}
else{
printf("%d is the greatest\n", c);
}
}
else{
if(b>c){
printf("%d is the greatest\n", b);
}
else{
printf("%d is the greatest\n", c);
}
}
// method 2
int max = (a>b)?((a>c)?a:c):((b>c)?b:c);
printf("%d is the greatest\n", max);
return 0;
}