I have an assignment for school and im kind of confused for how to do it... What im trying to do is have a user input up to 25 positive double values and the end of the input data is indicated by the user typing anynonnumeric value. Then i have to count how many values the user inputed and find the max and min numbers.
This is what I have so far but it isnt working :/
Code:
#include <stdio.h>
#include <stdlib.h>
int main() {
double numArray[25];
char wordArray[10];
int x = 0;
int y = 0;
double max = 0;
int counter = 1;
setvbuf(stdout, NULL, _IONBF, 0);
printf("Enter up to 25 positive reals (non-numeric to stop).\n");
scanf(" %lf %c", &numArray[x], &wordArray[y]);
max = numArray[0];
while (1) {
if ((numArray[x]) > max) {
max = numArray[x];
break;
}
counter = counter + 1;
x++;
}
printf("%d values were entered\n", counter);
printf("Max Value = %lf", max);
return EXIT_SUCCESS;
}