#include <stdio.h>
void main(){
int num[];
int jum;
int max,min,sum,nums;
float avg;
int i=0;
scanf ("Please enter the number of students." : : %d \n",&nums);
for(i=0;i<nums;i++){
scanf("Enter your score: %d",&num[i]);
if(num[i]<0||num[i]>100){
printf ("Please re-enter". \n");
}
if(num[i]<100 && num[i]>0){
continue;
}
sum+=num[i];
}
max=num[0];
min=num[0];
for(i=0;i==0;i++){
if(max<num[i]){
max=num[i];
}
if(min>num[i]){
min=num[i];
}
}
avg=sum/nums;
printf("Maximum value: %d\nMinimum value: %d\nAverage: %f\n", max, min, avg);
}
Question 1. You have to enter between 0 and 100 points, but if you go out of this range, the number of iterations, i, does not increase, and you can re-enter it. (continue) Is it okay to use it like that?
Question 2. I want to use max and min by adding scores to num[?] What should I put in the int num[?] question mark when declaring variables above?
c
© 2024 OneMinuteCode. All rights reserved.