A race has 5 rounds and a player can get a score between 0 - 8 in each round. The player
who obtained the highest average score is considered as the winner. Write a C program to
read the scores of a player of all 5 rounds from the key board and calculate and display the
average score. After entering the scores for one player, the program should ask from the
user whether he/she wants to enter the scores of another player. If user says 'y' or 'Y', the
program should continue entering the scores. If user says 'n' or 'N', the program should
stop reading scores from the keyboard.
Sample
output
Enter the scores of player 1(between 0 - 8)
round 1 - 3
round 2 - 2
round 3-3
round 4-6
round 5-5
average score - 3.8
Answers
Answer:
hehe I am a little bit of a place over a very long time ago the papers and vet e mail to inform you that I am a little bit of a place over a very long time ago the papers and vet e mail to inform you that I am a little bit of a place over a very long time ago the papers and vet e mail to inform you that I am a little bit of a place over a very long time ago the papers and vet e mail to inform you that I am a little bit of a place over
Explanation:
good morning mam Harshil varshney present invention the papers and vet e mail to inform you that I am a little bit of
Answer:
#include<stdio.h>
int main()
{
int a,b,c,d,e,sum;
int player=1;
char repeat;
float average;
while(1){
printf("\n\tEnter the scores of player %d(between 0 - 8)\n\n",player);
printf("round 1: ");
scanf("%d",&a);
printf("round 2: ");
scanf("%d",&b);
printf("round 3: ");
scanf("%d",&c);
printf("round 4: ");
scanf("%d",&d);
printf("round 5: ");
scanf("%d",&e);
sum = a+b+c+d+e ;
average = sum / 5.0 ;
player++;
printf("\naverage score %.2f",average);
printf("\nDo you want to enter the scores of another player (y/n):");
scanf(" %c",&repeat);
if(repeat=='y'|| repeat=='Y')
continue;
else if(repeat=='n' || repeat=='N')
break;
else
{
printf("invalid enter type");
break;
}
}
return 0;
}
Explanation: