Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <random>
- using namespace std;
- int main()
- {
- //seed random gen
- random_device seed{};
- // random gen
- mt19937 engine{ seed() };
- //uniform distribution
- uniform_int_distribution<> dis{ 1,10 };
- //output
- cout << "Welcome to multiply\n";
- cout << "Enter -1 to quit the program!\n";
- int userAnswer{};
- while (userAnswer != -1) {
- //generate 2 random ints
- int a{ dis(engine) };
- int b{ dis(engine) };
- cout << a << " * " << b << " = ? ";
- cin >> userAnswer;
- if (userAnswer == (a * b))
- {
- cout << "Correct!\n";
- }
- else if (userAnswer == -1)
- {
- cout << "Goodbye!\n";
- }
- else
- {
- cout << "Wrong!\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement