15,662,459 members
1.00/5 (1 vote)
See more:
I have written a program in C language. The program is designed for primary school students in Grades 1-2. Two integers are randomly selected, the numbers are either added or subtracted to form an equation, and the students are asked to solve the equation.

Criteria yet to be fulfilled:

At the end of the test, a message should appear prompting the player to choose "Show results", by entering the letter "S", "Play another round", by entering the letter "P", and "Quit", by entering the letter "Q". If the player entered "S" after one round of the game, output the player's score (marks/100). If the player chooses "Show results" after multiple rounds of the game, the output should include the player's highest score/%, lowest score/%, and the average score/% of all games played. If the player enters "Q", the program ends.

I have no idea how to output scores for the overall games played, so here's my not-so-bright attempt:

What I have tried:

```while (unsure)
{

unsure = false;
puts("Show results(S)");
puts("Play another round(P)");
puts("Quit(Q)");
char choice;
scanf("%c", &choice);
if (choice == 'Q')
done = true;
else if (choice == 'S') {
if (rounds == 1)
printf("Final score: %d/100\n", g);
else
{
puts("Whoops! Looks like highest/lowest have not been adjusted!");
printf("Highest score: %d/100\n", highest);
printf("Lowest score: %d/100\n", lowest);

}

getchar();

}

else if (choice == 'P')
{
// Do nothing?

} else
{

puts("Invalid input!");
unsure = true;

}

}
if (done) break;

}```
Posted
Updated 20-Nov-20 3:06am

## Solution 1

Capture the score for each question and add it to a total that you print at the end. You should stop writing code and start thinking about the logical steps required in your program. Create functions that provide each separate part and call each function from the main loop.

Top Experts
Last 24hrsThis month
 Graeme_Grant 30 OriginalGriff 20 Richard MacCutchan 20
 OriginalGriff 2,118 Graeme_Grant 928 Richard Deeming 718 Richard MacCutchan 638 Dave Kreskowiak 473

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900