Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Lec12.cpp
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- int main() {
- srand((unsigned int)time(0));
- cout << "Please enter 1 for multiplication or 2 for division: ";
- int math;
- cin >> math;
- while (true) {
- if (math == 1) {
- int randNum1 = 1 + rand() % 9;
- int randNum2 = 1 + rand() % 9;
- int ans = randNum1 * randNum2;
- while (true) {
- cout << "How much is " << randNum1 << " times " << randNum2 << endl;
- int StdAns;
- cin >> StdAns;
- if (StdAns == ans) {
- cout << "Very good!" << endl;
- break;
- }
- else if (StdAns != ans) {
- cout << "No. Please try again" << endl;
- }
- }
- }
- else if (math == 2) {
- int randNum1 = 100 + rand() % 9999;
- int randNum2 = 1 + rand() % 99;
- int ans1 = randNum1 / randNum2;
- int ans2 = randNum1 % randNum2;
- while (true) {
- cout << "What is " << randNum1 << " divided by " << randNum2 << endl;
- int StdAns1;
- cin >> StdAns1;
- if (StdAns1 == ans1) {
- cout << "Very good!" << endl;
- break;
- }
- else if (StdAns1 != ans1) {
- cout << "No. Please try again" << endl;
- }
- }
- while (true) {
- cout << "What is the remainder? " << endl;
- int StdAns2;
- cin >> StdAns2;
- if (StdAns2 == ans2) {
- cout << "Very good!" << endl;
- break;
- }
- else if (StdAns2 != ans2) {
- cout << "No. Please try again" << endl;
- }
- }
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement