This is a program that prompts the user of how many numbers they would like to enter. It is suppose to choose the smallest number. I think my problem is min isn't changing. I have tried a for statement to get min to change in relation to int1 but it doesn't seem to change min. What am I missing here?
Code:
#include <stdio.h>
4
5 int main (void)
6
7
8 {
9 float int1 = 0;
10 float min = 1;
11 float a, b;
12
13 printf("How many numbers would you like to compare?\n");
14 scanf("%f",&b);
15
16
17 for ( a = 1; a <= b; a++ ){ /* beginning of for loop */
18
19
20
21 printf("A is to %f\n",a);
22
23
24 printf("Enter intenger\n");
25 scanf("%f",&int1);
26
27
28
29 if ( int1 < min )
30 {
31 min = int1;
32 printf("The minimum is equal to %f\n",min);
33 }
34
35 }/* end for loop */
36
37 printf("The minimum value is %f\n",min);
38 return 0;
39
40 }
41
How many numbers would you like to compare?
4
A is to 1.000000
Enter intenger
1
A is to 2.000000
Enter intenger
2
A is to 3.000000
Enter intenger
3
A is to 4.000000
Enter intenger
4
The minimum value is 1.000000