So basically, one of my homeworks is to make a program that will ask arithmetic questions and some factoring questions to the user. The functions' purpose is to calculate how long it took the user to answer the questions and will return a certain number of points (Ill ask that question later on).
I just want to start the arithmetic questions for now.
So this is what I have so far:
Code:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define ADD 1
#define MULT 2
//These are the pre-functions, given from the homework outline.
double arithGAME (int max, int quantity, int op);
double factorGAME (int max, int quantity);
int numPoints ( double timesec);
int main () {
int game;
int choice, game_type;
int max_value, max_numb, numb_prob;
int max_questions;
while (game != 4){
printf("Please make a selection from the following:\n");
printf("1. Play Arithmetic Game.\n");
printf("2. Play Factoring Game.\n");
printf("3. Print Score.\n");
printf("4. Quit.\n");
//This is the part where the user will choose what type of game
scanf("%d", &game);
//This is Game 1, which is the arthimetic game
if (game==1){
printf("Would you like, 1)Addition or 2) Multiplication?\n");
scanf("%d", &choice);
if (choice==1)
game_type= ADD;
else
game_type = MULT;
printf("What is the maximum number you would like?\n");
scanf("%d", max_numb);
printf("How many problems do you want?\n");
scanf("%d", max_questions);
arithGAME (max_numb, max_questions, game_type);
}
//This is Game 2, which is the factoring game
else if (game==2){
printf("Enter the maximum value of a factor");
scanf("%d", &max_value);
printf("How many factoring problems do you want?");
scanf("%d", &numb_prob);
factorGAME( max_value, numb_prob);
}
//This choice 3, which prints out the score
else if (game==3){
}
}
system("PAUSE");
return 0;
}
//These are the Function's presets
//This the Arthicmetic function
double arithGAME (int max, int quantity, int op) {
srand(time(0));
}
//This is the Factoring function
double factorGAME (int max, int quantity) {
// srand(time(0));
}
Mainly, I need help setting up the questions.
I want the outline to start something like:
Please make a selection from the following:
1. Play Arithmetic Game.
2. Play Factoring Game.
3. Print Score.
4. Quit.
1
Would you like, 1)Addition or 2)Multiplication?
1
What is the maximum number you would like?
100
How many problems do you want?
4
What is 21+86?
107
Correct, great job!
What is 87+96?
173
Sorry, that's incorrect, the answer is 183.
What is 86+70?
156
Correct, great job!
What is 55+4?
59
Correct, great job!
So my question is, when setting up the questions, do I put in the main function, or separate function?