Last question!

I'm on my last question, and I have no idea where I start. I tried though.

A bowling team consists of five players. Each player bowls three games. Write a C program that uses a nested loop to enter each players individual scores and then computes and displays the average score for each bowler. Assume that each bowler has the following scores:

1st bowler: 286 252 265
2nd bowler: 212 186 215
3rd bowler: 252 232 216
4th bowler: 192 201 235
5th bowler: 186 236 272

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdio.h>
int main()
{
	float averageScore;
	int bowler;
	int score1;
	int score2;
	int score3;
	for (bowler=1;bowler<=5;bowler++)
{
	averageScore=0;
	for(score1;score<=2;score++){
	printf("1st bowler: Average score for bowler 1 is %3.2f\n", averageScore)
	averageScore= (score1+score2+score3)/(3)
	}
}
}
Here is what it should look like:

http://snag.gy/mWslJ.jpg
Last edited on
What I would do is create a static array like
1
2
const int Players = 5;
double PlayerAverageScore[Players];
you must initialize them to 0. PlayerAverageScore[Players] = {0.0}; Then have one variable for inputting like int Score; in your loop you will have to get 3 inputs for each score then add them to the average score of that player and then divide by 3 (number of scores).

Something like this to get you started:

1
2
3
4
5
6
7
8
const int bowlers = 5;
for( int bowler = 0; bowler < bowlers; ++bowler )
{
    //read in 3 scores and add to average score
   //divide the average score of that player by 3
}

//output the players average scores. 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdio.h>
int main()
{
	float averageScore;
	int bowler;
	int score1;
	int score2;
	int score3;
	const int bowlers = 5;
for( int bowler = 0; bowler < bowlers; ++bowler )
{
   scanf("%d")
}

//output the players average scores. 

	}


is what I've got. Sorry I'm a bit slow today.
Last edited on
Topic archived. No new replies allowed.