I'm trying calculate the average of 5 numbers, all of them being lower than 10. Any help would be much appreciated since I'm still very much in the early stages of learning.
int num1, num2;
int sum, i;
float average;
printf ("Enter five numbers to calculate the average:");
for (i = 0; i < 5; i++){
scanf ("%d", num1);
if (num1 > 10){
printf ("You can't enter this number\n");
printf ("Enter five numbers to calculate the average:");
scanf ("%d", num1);
}
else{
num1=num2;
}
sum += num2;
}
average = sum / 5;
printf ("Average is: %f", average);
Aucun commentaire:
Enregistrer un commentaire