Nested Loops


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

I tried asking a few days ago but I was in a rush. I am kinda in one right now too but not so bad.

Here's my problem, I usually can figure these things out pretty quick but this nested loop has got me crying for mama...or yet cplusplus gurus. I've got this much so far. I know its a mess but please help me out!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  #include <stdio.h>
int main()
{
	float averageScore;
	int count;
	int score;
	char bowler;
for( bowler = 0; bowler<=5; bowler++ ){
bowler=0;
   for(count=1;count<=3;count++);{
   switch (bowler)
{
    case 1:
        printf("1st bowler:  ");
        break;
    case 2:
        printf("2nd bowler:  ");
        break;
    case 3:
    	printf("3rd bowler:  ");
    	break;
   }
   averageScore=(score+score+score)/3;
   printf("1st bowler:  Average score for bowler 1 is %.2f\n", averageScore);
}


return 0;

	}
I'll post a screen shot of what it should look like

here it is

http://snag.gy/u31YC.jpg
Last edited on
Seems like bowler should be an int not a char?

If you start bowler at 0 and go up to 5, the loop will run 6 times - I think you only mean it to run 5.

You then reset bowler = 0, but then try to use bowler as the switch condition - it's not going to match your cases of 1 through what I guess will be 5?

Topic archived. No new replies allowed.