-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnested_if_statements.c
50 lines (46 loc) · 959 Bytes
/
nested_if_statements.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
49
50
/**
* @file nested_if_statements.c
* @author PantheraRed
* @brief A C program to demonstrate the use of nested if statements.
* @version 0.1
* @date 2022-07-17
*
* @copyright Copyright (c) 2022
*
*/
#include <stdio.h>
int main()
{
int a, b, c;
printf("Enter 1st number: ");
scanf("%d", &a);
printf("Enter 2nd number: ");
scanf("%d", &b);
printf("Enter 3rd number: ");
scanf("%d", &c);
// If a is greater than b, then check if a is also greater than c
if (a > b)
{
if (a > c)
{
printf("%d is the largest number\n", a);
}
else
{
printf("%d is the largest number\n", c);
}
}
// Else check if b is greater than c
else
{
if (b > c)
{
printf("%d is the largest number\n", b);
}
else
{
printf("%d is the largest number\n", c);
}
}
return 0;
}