So I\'m coding in C, and I need to come up with code that will take n numbers from the user, and find their minimum, maximum, average, and sum of squares for for their values. S
There're some issues in your code:
num
is read? You should do it before min
and max
num
to max
and min
. Something like that:
int min = 0;
int max = 0;
// If your compiler supports C99 standard you can put
// bool first_time = true;
int first_time = 1;
while (count < n) {
printf("Please, enter the next number\n");
scanf_s("%d", &num);
// If your compiler supports C99 you can put it easier:
// if (first_time) {
if (first_time == 1) {
first_time = 0;
max = num;
min = num;
}
else {
if(num > max)
max = num;
if(num < min)
min = num;
}
...