Radeen10-_

Guessing Number

Sep 19th, 2021
743
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <ctime>
  3.  
  4. using namespace std;
  5. int main(){
  6.     int hostUserguess, guestUserguess, chances=0;
  7.     cout <<" give your character: ";
  8.     srand(time(0));
  9.     hostUserguess=1+rand()%100; //random number between 1 to 10
  10.     do
  11.     {
  12.         cout<< "guess a number between 1 to 10:\n";
  13.         cin>> guestUserguess;
  14.         chances++;
  15.         (hostUserguess>guestUserguess)? cout<<"too low\n" :(hostUserguess<guestUserguess)?
  16.          cout<< "too high\n" : cout<< "\ncorrect! you got it in "<< chances<<" guesses!\n";
  17.        
  18.     } while (guestUserguess!=hostUserguess);
  19.     return 0;
  20.    
  21.    
  22.  
  23. }
RAW Paste Data