Advertisement
DrDiagramm

Untitled

Feb 9th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. #include <string>
  5. int guess();
  6. int randNumb();
  7. int main() {
  8. int guNum;
  9. std::string question;
  10. srand(time(0));
  11. int passed = 0;
  12.  
  13. std::cout << "Guessing Game! Try guessing the Number, from 1-9000\n\n";
  14.  
  15. int ranNum = randNumb();
  16. std::cout << "Guess the Number now! ";
  17.  
  18.  
  19. while (passed!=1) {
  20.  
  21. int guNum = guess();
  22. if (guNum == ranNum) {
  23. std::cout << "Yes! Thats right!!!\n\n";
  24. int passed = 1;
  25. break;
  26.  
  27. }
  28.  
  29. else if (guNum > ranNum) {
  30. std::cout << "The guessed number is bigger than the wanted number.\n";
  31.  
  32. }
  33. else {
  34. std::cout << "The guessed number is smaller than the wanted number.\n";
  35. }
  36. }
  37.  
  38. system("pause");
  39. return 0;
  40. }
  41. int randNumb() {
  42. int i = 1 + (rand() % 9);
  43. return i;
  44.  
  45.  
  46. }
  47. int guess() {
  48. int j;
  49. std::cin >> j;
  50. return j;
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement