Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- using namespace std;
- int main(){
- int hostUserguess, guestUserguess, chances=0;
- cout <<" give your character: ";
- srand(time(0));
- hostUserguess=1+rand()%100; //random number between 1 to 10
- do
- {
- cout<< "guess a number between 1 to 10:\n";
- cin>> guestUserguess;
- chances++;
- (hostUserguess>guestUserguess)? cout<<"too low\n" :(hostUserguess<guestUserguess)?
- cout<< "too high\n" : cout<< "\ncorrect! you got it in "<< chances<<" guesses!\n";
- } while (guestUserguess!=hostUserguess);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement