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??

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string.h>

int randomNumbers(){

rand() % 100 + 1;
}
int num(){
randomNumbers();
}
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;
}

#1) Learn to format your code so it's readable
#2) Isn't y a single character? What's the proper printf() format specifier for a character?

That should help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.