CS167467 C Programming
Fall 1999
Multiplication practice
Goals
To write a program that uses library functions, and functions as modules to contain subtasks.
Problem description
Write a C program that will help an elementary school student practice multiplication facts. Use the library function
rand to generate two single digit numbers to be multiplied. Print a question like:
How much is 6 times 7?
After the student types an answer the program should check it and display a message., such as "Very good!" or "No, it’s 42", and then ask another question. Use
rand again to choose one of a samll number of different messages to be displayed in response to the answer. Keep track of the correct and incorrect answers, and print the percentage of correct answers at the end of the session. The student can indicate he wants to stop by typing 9999 as the answer to a question.
Procedure
Follow these steps to end up with a successful program:
- Think of the program in terms of at least three separate subtasks, which you should write as separate functions:
- generating the question
- getting the answer from the student and checking it
- printing the response
- Write the main program to call these three functions appropriately.
- Use
srand(time(NULL)) to "re-seed" the random number generator so that the program will produce different questions every time it is run.
Deliverables:
your source code, suitably commented and with good layout
the output produced by the program for four questions
your source code e-mailed to the grader, login name byao.
Notes and hints
the program is an example of a "loop" program where the main task is a loop of some sort. Input is done within the loop. The output phase, is separate, however, and is done after all input and processing have been completed.
prompt the user for input, mentioning especially the sentinel value (see page 69) used for teminating the input.
display screen output with reasonable layout
put the include directives for stdlib.h and time.h at the top of your source code
Due Date
Submit your completed assignment before 5pm. on Friday October 8th.