Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<time.h>
- #include<stdlib.h>
- using namespace std;
- int main()
- {
- cout << "Hello and welcome to number guesser" << endl << "Please guess a number from 1 - 10" << endl;
- srand(time(NULL));
- int GeneratedNumber = rand () % 10 + 1;
- int Input;
- for (int Lives = 3; Lives > 0; Lives--)
- {
- cout << "Your guess?" << endl << ">";
- cin >> Input;
- if(Input == GeneratedNumber)
- {
- cout << endl << "You got it!" << endl;
- Lives = 0;
- }
- else if (Input < GeneratedNumber) cout << endl << "Too small!" << endl;
- else cout << "Too big!" << endl;
- }
- if (GeneratedNumber != Input) cout << "You died..." << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment