# Thread: A Different Bowling Program

1. ## A Different Bowling Program

I am trying to create a C program to calculate bowling scores (this is not the same as the other bowling problems posted here). I am having trouble figuring out where to go when a strike is encountered without using 1000 if statements. I would greatly appreciate any help i can get with either logic or code.

Here is a stripped down version of my code (no fancy display), it contains only the scoring functions. I have heard that a struct or a flag might help me, but i am not very familiar with them yet so i am heading to look them up now. Again, any help would be greatly appreciated. Thanks.

Code:
```#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "math.h"

int main(void)
{
FILE *fp;
char c;
int i = 0;
int j = 0;
int players = 0;
int frame[10][2];
int total_score = 0;

for(i = 0; i<10; i++)
{
for( j = 0; j<2; j++)
{
if( j == 0)
{
printf("Did You get a strike? y/n?");
fflush(stdin);

{
printf("STRIKE!!!\n");
j = j+2;
// strike function
}
else
{
printf("Enter Score for Frame %i Ball %i\n", i+1,j+1);
scanf("%i", &frame[i][j]);
fflush(stdin);
total_score = total_score + frame[i][j];
printf("Total Score is %i\n", total_score);
}
}
if(j == 1)
{
printf("Did You get a spare? y/n?");
fflush(stdin);

{
printf("spare\n");
// spare function
}
else
{
printf("Enter Score for Frame %i Ball %i\n", i+1,j+1);
scanf("%i", &frame[i][j]);
fflush(stdin);
total_score = total_score + frame[i][j];
printf("Total Score is %i\n", total_score);
}
}
}
}
system("pause");
return(0);```

2. Code:
`fflush(stdin);`
X strike one

3. Yes indeed, fflush() is undefined on input buffers.

But I don't entirely see where you would need many if-elses in the case of a strike. You should tell us what you intent to happen after a strike, then we might be able to clue you in.

4. Originally Posted by sand_man
Code:
`fflush(stdin);`
X strike one
You're confusing bowling with baseball. In bowling it's good to get a strike.

Quzah.