Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- using namespace std;
- int main ()
- {
- srand(static_cast<unsigned int>(time(0)));
- int count=1;
- int num =rand()% 10+1;
- int guess;
- char answer;
- int n;
- do
- {
- cout << "guess a number between 1 & 10" << endl;
- cin >> guess;
- while (guess != num)
- {
- count++;
- cout <<"guess a number between 1 & 10 " << endl;
- cin >> guess;
- }
- cout << "It took " << count << " guesses to guess correctly" <<endl;
- cout << " would you like to play again (y/n) " << endl;
- cin >> answer;
- }
- while (answer != n );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement