// Torrez, Elaine CS1A Chapter 3 P. 146, #15
/******************************************************************************************
*
* CREATE MATH TUTOR PROBLEM
*
* --------------------------------------------------------------------------------
* This program generates two random numbers and displays them as an addition
* problem for the student to solve. The student presses Enter to see the solution.
* --------------------------------------------------------------------------------
*
* INPUT
* (Press Enter key to check answer)
*
* OUTPUT
* num1 : First random number
* num2 : Second random number
* total : Correct sum (num1 + num2)
*
*******************************************************************************************/
#include <iostream>
#include <cstdlib> // For rand() and srand()
#include <ctime> // For time() to seed random generator
using namespace std;
int main ()
{
int num1; // First random number
int num2; // Second random number
int total; // Correct sum
// Seed random number generator
srand(time(0));
// Generate two random numbers between 100 and 999
num1 = rand() % 900 + 100;
num2 = rand() % 900 + 100;
// Calculate total
total = num1 + num2;
// Display the problem
cout << " " << num1 << endl;
cout << "+ " << num2 << endl;
cout << "------" << endl;
// Pause until student presses Enter
cin.get();
// Show the answer
cout << " " << total << endl;
return 0;
}