int main(){
int size;
char run[4]="yes";
while (!strcmp(run,"yes")){ //allows the program to run while the variable 'run' is equal to yes (Found this function on www.cplusplus.com)
printf("How many test scores do you want to enter? (Maximum of 30) ");
scanf("%d",&size); //assigns the value entered as the variable 'size'
if(size<2 || size>30){ //Checks if the number of test scores is not between 2 and 30 then the program doesn't run as it would error
printf("The number of test scores must be at least 2 but not exceed 30."); //error message
} else { //runs main program
enter_values(size); //runs the function 'enter_values'
printf("\n--------Statistics--------\n");
printf("The mean is %1.2f\n",mean(size)); //calls the mean function to work out the mean
printf("The maximum value is %1.2f\n",maximum_value(size));
printf("The minimum value is %1.2f\n",minimum_value(size));
printf("The standard deviation is %1.2f\n",stddev(size));
}
printf("\n\nDo you want to run the program again? (yes/no)"); //asks the user if they want to run the program again
scanf("%s",&run);//assigns their answer to 'run'
}
}
The program works but I get a warning saying "warning 511 - Character pointer expected to satisfy %s format"
run is already a pointer (the name of an array converts to a pointer to its first element). Remove the ampersand.
Notice your code is very unsafe. What if the user types in more than 3 characters? You can determine the size of the input you want by saying this instead: