-
Notifications
You must be signed in to change notification settings - Fork 1
/
exam.cpp
51 lines (44 loc) · 1 KB
/
exam.cpp
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
#include<stdio.h>
int main()
{
double a, b, c;
printf("Enter 3 numbers:\n");
scanf("%lf%lf%lf", &a, &b, &c); //lf is a format specifier to take double as input
// a is the largest
if(a >= b && a >= c)
{
if(b >= c)
{
/*
.2lf restricts the number till
2 decimal places
*/
printf("\n\n%.2lf is the 2nd largest number\n", b);
}
else
{
printf("\n\n%.2lf is the 2nd largest number\n", c);
}
}
else if(b >= a && b >= c)
{
if(a >= c)
{
printf("\n\n%.2lf is the 2nd largest number\n",a);
}
else
{
printf("\n\n%.2lf is the 2nd largest number\n",c);
}
}
// c is the largest number of the three
else if(a >= b)
{
printf("\n\n%.2lf is the 2nd largest number\n", a);
}
else
{
printf("\n\n%.2lf is the 2nd largest number\n", b);
}
return 0;
}