Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ctime>
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- int randRange(int, int);
- int main() {
- int HiddenNumber = 0;
- int Input = 0;
- srand(time(NULL));
- HiddenNumber = randRange(1, 101);
- cout << HiddenNumber << endl;
- while (Input != HiddenNumber)
- {
- cout << "Can you guess what's the hidden number (1 - 100): ";
- cin >> Input;
- if (Input > HiddenNumber) {
- cout << "Your guess number is too high" << endl;
- }
- else if (Input < HiddenNumber) {
- cout << "Your guess number is too low" << endl;
- }
- }
- cout << "Your answer is correct!" << endl;
- }
- int randRange(int low, int high) {
- return rand() % (high - low) + low;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement