Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <chrono>
- int main()
- {
- int secret{ 0 };
- int guess{ 0 };
- srand(time(0));
- secret = rand() % 51;
- std::cout << "Try to guess my number from 1 to 50\n";
- do
- {
- std::cout << "Enter your number...\n";
- std::cin >> guess;
- if (guess == secret)
- {
- std::cout << "Wow! You did it! Secret number was " << secret << ". Well done!\n";
- }
- if (guess > secret)
- {
- std::cout << "My number is smaller than yours! Try again!\n";
- }
- else
- {
- std::cout << "My number is greater than yours! Try again!\n";
- }
- } while (guess != secret);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement