5 x 2 =
Assuming 5 and 2 are the randomly generated operands.
The user at this point will enter the answer followed by the enter key. The entered value is compared with the computer calculated answer. If they are the same, a counter representing the correctly answered questions is incremented; along with a message indicating the answer was answered correctly. If the answer entered is incorrect, then a message indicating the answer was incorrectly answered should be displayed.
Each test comprises of 10 questions; The question number will be displayed as a prefix to the question displayed.
After the 10 questions have been answered, the score as a percentage is displayed. e.g. “You answered 70% of the questions correctly”
The user is then asked if they would like another go? Entering ‘Y’ will start the test again, after clearing the screen.
so far my code is
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int firstrandom; //first random number to be generated declared as an integer
- int secondrandom; //second random number to be generated declared as an integer
- int guess;
- int answer;
- int counter;
- int quesnum;
- void main (void)
- {
- printf("What is the product of the following questions?\n\n");
- srand (time(NULL));
- firstrandom = rand() % 12 + 1;
- secondrandom = rand() % 12 + 1;
- answer = firstrandom * secondrandom;
- printf("Q1\n\n");
- printf("%d\n", firstrandom);
- printf("%d\n", secondrandom);
- }