Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi really need help with this please. It is supposed to be a program that mimicks score keeping in the game of bowling. I input how many pins on each ball i got. The 10 frame is handled differently if it is a strike or spare. I really need help with getting it to run. The language is C and it is supposed to be simple..nothing more advanced then what is below. Below is the code that I have. Any help will be much appreciated!!
void main ()
{
int i,score[10], ball[2][12];
printf("Hello and Welcome to the Blinn Bowling Center");
//To get input of all balls
for (i = 0; i 10 || ball[0][i] 10 || ball[1][i] 10)
printf("Sorry, Bad input,try again");
else
if (ball[0][i] + ball[1][i] == 10)
printf("Not Bad...Spare!");
else
continue;
if (ball[0][9] == 10)
printf("Please input ball [2][i]: ");
printf("Please input ball [3][i]:");
//Need to figure out score[0] first;
for (i = 1; i 9; i++)
if (ball[0][i] == 10)
if (ball[0][i + 1) == 10)
score[i] = score[i-1] + ball[0][i] + ball[0][i + 1]
+ ball[0][i + 2];
else
score[i] = score[i - 1] + ball[0][i] + ball[0][i +
1] + ball[1][i + 1];
else
if (ball[0][i] + ball[1][i] == 10)
score[i] = score[i - 1] + 10 + ball[0][i +1);
else
score[i] = score[i -1] + ball[0][i] + ball[1][i];
//Handle 10th frame, if it is strike or spare

I see a couple problems. In the section:
for (i = 0; i 10 || ball[0][i] 10 || ball[1][i] 10)
printf("Sorry, Bad input,try again");
else
if (ball[0][i] + ball[1][i] == 10)
printf("Not Bad...Spare!");
else
continue;The for loop should have an i++ should it not?
What is the else before the if with?
Did you want the if included in the for loop? If so,
put a { after the for loop, and a
} at the end of the section to be
included.
Also, I'm not familiar with the continue command,
maybe someone else can help you with that one.

This line of code:
for (i = 0; i 10 || ball[0][i] 10 || ball[1][i] 10)
Is missing the conditional operator between the i and the 10, as well as after your arrays (basically, you need a conditional operator to the left of all the 10s in this line of code.
In this line of code:
for (i = 1; i 9; i++)You are missing the condition between i and 9.
In the next line of code:
if (ball[0][i + 1) == 10)You are missing a closing ] right where you put the extra ), this should read ....[i+1]...
Same thing in this line of code...
score[i] = score[i - 1] + 10 + ball[0][i +1);It should read ....[i+1];
You may also need to include a set of { }, depending on how you want your program to operate.
When you accomodate these errors, the continue statement should work itself out.
Hope this helps.
Infinite Recursion

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |