hello everyone so im trying to make my program read a bunch of numbers in an array to find its maximum and minimum. the program will ask the user to enter in as much number as possible until they enter a non number/letter. i got my program to find the maximum value but the program couldn't read the minimum value. it always says zero. also everytime i enter the number 0, the program will just finish its loop statement. If i typed in a negative number, it'll read the negative number as its minimum.
Code:#include <stdio.h> int main() { //-------variables------------------ double list[1000]; // can hold 1000 items int i; char letter; int max = list[0]; int min = list[0]; printf("Please enter a number\n"); /* initialize the array items */ for (i = 0; i < 1000; ++i) { scanf("%lf", &list[i]); if(list[i] > max) { max = list[i]; } if(list[i] < min) { min = list[i]; } if(list[i] == letter) { printf("the maximum element in the array is :%i\n", max); printf("the minimum element in the array is :%i\n", min); getch(); } } }