-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexp-4-2.c
More file actions
51 lines (44 loc) · 911 Bytes
/
exp-4-2.c
File metadata and controls
51 lines (44 loc) · 911 Bytes
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
51
/*************************************************************************
> File Name: exp-4-2.c
> Author: xiaoxiaoh
> Mail: xiaoxxhao@gmail.com
> Created Time: Fri Jun 30 10:16:16 2017
************************************************************************/
/*
* Write a C program to find maximum between three numbers using nested if.
*
* Example
*
* Input
* Input num1: 10
* Input num2: 20
* Input num3: 15
*
* Output
* Maximum is: 20
*
*/
#include <stdio.h>
int main()
{
int num1, num2, num3, max;
//read three numbers from user
printf("Enter three numbers one by one: ");
scanf("%d%d%d", &num1, &num2, &num3);
if(num1 > num2)
{
if(num1 > num3)
max = num1;
else
max = num3;
}
else
{
if(num2 > num3)
max=num2;
else
max=num3;
}
printf("The maximum between three numbers max(%d, %d and %d) ==> %d\n", num1, num2, num3, max);
return 0;
}