gentlemen... I don't want you to solve it for me all what I want is to give me some hints how to solve this question...
for example what kind of function you recommend me to use and what kind of loops you recommend me to use also .....
Write a program to test kid’s knowledge of arithmetic.
Your program contains 3 functions in addition to the main function;
- Function randnum(int n) receives a positive integer n and returns a random number between 1 and n.
- Function randop() return a character representing the operation i.e. ‘+’ for addition, ‘-‘ for subtraction and ‘*’ for multiplication. The function will generate a random number between 1 and 3 ( call randnum function for this) and returns ‘+’ if it’s 1, ‘-‘ if 2, and ‘*’ if it’s 3.
- Function operation receives 2 operands n1 and n2 and the operator (+ or – or *) and returns the result (i.e. n1 operator n2).
The main function will use a do-while loop to keep the test running as long as the user types ‘Y’ or ‘y’.
The addition and subtraction will be with numbers from 1 to 20
The multiplication with numbers from 1 to 10.
Note: The function rand() will return a pseudo random number from 0 to RAND_MAX which is the maximum value in the int type. In order to limit your number from 0 to n, make the returned value % (n+1). By using rand() only, your program will generate the same sequence during each execution. To avoid this problem insert the following statement at the beginning of your main function. srand(time(NULL));
You need to insert 2 include statements <stdlib.h> and <time.h>.
Initially the program will post the first operation and wait for the answer. Then based on the typed answer, the program will print “wow you got it right” or “oops you missed it”. In this case it prints the right answer.