Hello, I'm learning to Program in C and I have to create a math quiz. The user is supposed to enter the amount of questions they want to answer. I'm trying to get a Random number generator to produce two random numbers and then a random sign (+ - * /) so basically it looks like this (Ex. 4+4 = ) Then the user inputs the answer and it goes on to the next question till the person answered all of them. Then I wanted a text file that containted all the questions and answers..

Here is what I have so far... which is reall slim..any ideas??


int randomNumbers(){

rand() % 100 + 1;
int num(){
char sign(){
int equation(int a, int b, char c){
int randomSign(){
int sign = 1 + rand() % 5;
if (sign == 1)
return '+';
if (sign == 2)
return '-';
if (sign == 3)
return '*';
if (sign == 4)
return '/';
if (sign == 5)
return '%';

int main(){

int correct = 0;
int x, y, answer, correctanswer;
char z;

x = num();
y = num();
z = sign();

printf(" %d %s %d =", x,y,z);

return 0;
9 Years
Discussion Span
Last Post by WaltP
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.