Help with a Program in C?

Hi, i have been given this assignment in my Intro to Programming class for my third assignment. I have no clue where to begin, and seeing that i'm just starting at programming, this just feels way out of my league. I haven been to the tutors at my school, and get this, they haven't learned to program in C, just C++. Im not worried about getting a 100% on this program, i just need something. So any help would be greatly appreciated.

Create a program that presents the user with a multiple choice quiz. The user will be presented with five questions, a question at a time with the choice of four possible answers. The user will input an answer "a", "b", "c", "d". in response to a question. The program will keep track of the right or wrong scores for each question and give a final grade report once the quiz is finished. The final report will give right or wrong for each question as well as the average grade and assign a letter grade based on the final average. The user should be given the choice to take the quiz again or to quit the program.

2 Answers

Relevance
  • 8 years ago
    Favorite Answer

    Normally, a program like this would go one step further -- supporting multiple tests -- and it would provide a menu for selecting the test they want to take. The tests would be stored as "text files" which would be "parsed" much like parsing an HTML file might be done, and then presented to the user in a convenient, readable form. But as you say, you are "just starting." So that's out.

    I would prefer the idea that you simply write a program to read something like the following:

    1.  What is 5+6?

        a.      10

        b.      11

        c.      12

        d.      13

    And learn to parse out the options in the file (find a, b, c, and d) and then modify your program to adapt to that. This makes it really easy to change the test without needing to recompile your program. But it also requires you to write some code that can "interpret" the above text as it reads it from a file. And so this is probably also "out" given your knowledge level. (It's not hard, but any addition of difficulty at this point is probably unwanted.)

    So that leaves you with needing to write something along the following lines:

        do {

            Set number of correct answers to zero, to start

            Display question 1

            Accept user response to question 1

            If answer given is correct, add 1 to the number of correct answers

                and set a special "Q1" variable to true (otherwise false)

            Display question 2

            Accept user response to question 2

            If answer given is correct, add 1 to the number of correct answers

                and set a special "Q2" variable to true (otherwise false)

            Display question 3

            Accept user response to question 3

            If answer given is correct, add 1 to the number of correct answers

                and set a special "Q3" variable to true (otherwise false)

            Display question 4

            Accept user response to question 4

            If answer given is correct, add 1 to the number of correct answers

                and set a special "Q4" variable to true (otherwise false)

            Display question 5

            Accept user response to question 5

            If answer given is correct, add 1 to the number of correct answers

                and set a special "Q5" variable to true (otherwise false)

            Report the results of Q1 through Q5 (report status of each answer)

            Report number of correct answers (wrong will be [5 - correct])

            Report average as "correct divided by 5" as a percentage

            Report the letter grade (I don't know how that is decided)

            Ask if the user wants to take it again

        } while (answer is yes);

    It's boiler-plate code. Not flexible, as you have to recompile every time something changes about it. But that's probably the brute force method to take.

  • Anonymous
    4 years ago

    no longer anymore, at one time C++ became basically an extension of C. because of the fact then, C has replaced, and so has C++. even nonetheless that being reported that's commonplace for the same application to collect the two C and C++. the technique is the same, yet there are in ordinary terms some changes int he libraries which you extremely want the compiler to link to.

Still have questions? Get your answers by asking now.