Skip to content

Commit 42293c3

Browse files
authored
greatmo
C Program to Find the Largest Number Among Three Numbers
1 parent c5c05c2 commit 42293c3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

greatmo

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <stdio.h>
2+
int main() {
3+
double n1, n2, n3;
4+
printf("Enter three different numbers: ");
5+
scanf("%lf %lf %lf", &n1, &n2, &n3);
6+
7+
// if n1 is greater than both n2 and n3, n1 is the largest
8+
if (n1 >= n2 && n1 >= n3)
9+
printf("%.2f is the largest number.", n1);
10+
11+
// if n2 is greater than both n1 and n3, n2 is the largest
12+
if (n2 >= n1 && n2 >= n3)
13+
printf("%.2f is the largest number.", n2);
14+
15+
// if n3 is greater than both n1 and n2, n3 is the largest
16+
if (n3 >= n1 && n3 >= n2)
17+
printf("%.2f is the largest number.", n3);
18+
19+
return 0;
20+
}

0 commit comments

Comments
 (0)