Click here to Skip to main content
14,924,633 members
Please Sign up or sign in to vote.
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)");
            char choice;
            scanf("%c", &choice);
            if (choice == 'Q')
                done = true;
            else if (choice == 'S') {
                if (rounds == 1)
                    printf("Final score: %d/100\n", g);
                    puts("Whoops! Looks like highest/lowest have not been adjusted!");
                    printf("Highest score: %d/100\n", highest);
                    printf("Lowest score: %d/100\n", lowest);


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

            } else

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

        if (done) break;
Updated 20-Nov-20 3:06am

1 solution

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.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

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