I am working on a math tutoring program that asks the user for a seed value, gives them two random numbers from 1 to 500, and asks them to key in the correct answer. So far, here is my source code:
#include <iostream>
#include <cstdlib>
#include <time>
#include <conio>
using namespace std;
int main()
{
unsigned seed;
int = rand();
cout << "Enter a seed value: " ;
cin >> seed;
srand(time(0));
cout << rand()%500 <<endl;
cout << rand()%500 <<endl;
sum = rand() + rand();
cout << "What are the sum of the two numbers? " ;
cin >> sum;
getch();
return 0;
}
However, I am so confused right now: I've feel as if I've hit a brick wall.
Here's my problem:
- I have no idea how to check and see if the number that they input is the correct answer. (I know it has something to do with the if/else loop). Is there a variable that I have to use??
- I don't know what formula to use to add the two random numbers up. I tried
int num = rand
at the suggestion of someone, but Ive deleted that part because I couldn't figure out where it went. :cry: I've even tried to declare rand() as an int variable, but all I got was an error message.
Please keep in mind that I am new at this C++, and I am here to learn. :eek: I type this program myself, I've read my textbook, and I still got stuck. Please help me. :sad: