-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgreatest_iff.c
48 lines (41 loc) · 1.5 KB
/
greatest_iff.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
48
// This is the program for finding greatest among 3 number using if else statement
/* Sample Input :
Enter the first number : 14
Enter the first number : 15
Enter the first number : 10
Sample Output :
The 15 is greatest.
*/
#include <stdio.h>
void main()
{
int x , y , z ; // variable declaration
printf("Enter the first number :");
scanf("%d",&x); // input first number
printf("Enter the second number :");
scanf("%d",&y); // input second number
printf("Enter the third number :");
scanf("%d",&z); // input third number
if (x > y) // checking greatest among number 1 and number 2
{
if (x > z) // if the first one is greater then check with 3rd one
{
printf("The %d is greatest.",x); // if above is true then number 1 is greatest else 3rd one is greater
}
else
{
printf("The %d is greatest.",z);
}
}
else // if number 2 is greater then compare with 3rd number.
{
if (y > z) // if true number 2 is greater else number 3 is greater
{
printf("The %d is greatest.",y);
}
else
{
printf("The %d is greatest.",z);
}
}
}