Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <time.h>
  4.  
  5. using namespace std;
  6. // game of guessing number;
  7. int main()
  8. {
  9. srand(time(0));
  10. int number;
  11. number = rand() % 100 + 1;
  12. int guess;
  13.  
  14.  
  15. do {
  16. cout <<"Enter your estimate guess: "<<flush;
  17. cin >> guess;
  18. if (guess < number){
  19. cout << "Your guess is less than the secret number" << endl;
  20. }
  21. else if (guess > number){
  22. cout << "Your guess is more than the secret number" << endl;
  23. }
  24. else{
  25. cout << "Your guess is right!" << endl;
  26. cout << "Congratulation!!!!!!!!" << endl;
  27. }
  28.  
  29. }while(guess != number);
  30. system("PAUSE"); // prevent the consol from closing;
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement