1234567891011121314151617181920212223242526272829303132333435363738
// Includes #include "stdafx.h" #include <iostream> #include <cstdlib> #include <ctime> using namespace std; // Main Function int main() { srand(time_t(NULL)); int random1 = 1 + (rand() % 1000); int random2 = 1 + (rand() % 1000); double answer; double correct; cout << "This program is a math tutor.\n\n"; cout << "Generates 2 random numbers." << endl; cout << "\n\n" << " " << random1 << endl; cout << " + " << random2 << endl; cout << "\n\nPlease enter your answer: "; cin >> answer; correct = random1 + random2; if (answer == correct) { cout << "Good Job, you got it right."; } else { cout << "OH NO, you got it wrong." << endl; cout << "The correct answer is: " << correct << endl; } return 0; }
srand(time_t(NULL));
srand(time(NULL));