-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.1.c
37 lines (28 loc) · 836 Bytes
/
2.1.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
//find the smallest number amoung the four numbers
#include <stdio.h>
int main() {
float num1, num2, num3, num4, smallest;
// Input the four numbers
printf("Enter the first number: ");
scanf("%f", &num1);
printf("Enter the second number: ");
scanf("%f", &num2);
printf("Enter the third number: ");
scanf("%f", &num3);
printf("Enter the fourth number: ");
scanf("%f", &num4);
// Assume the first number is the smallest
smallest = num1;
// Check and update if any of the other numbers is smaller
if (num2 < smallest) {
smallest = num2;
}
if (num3 < smallest) {
smallest = num3;
}
if (num4 < smallest) {
smallest = num4;
}
printf("The smallest number is: %.2f\n", smallest);
return 0;
}