Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- #include <string>
- int guess();
- int randNumb();
- int main() {
- int guNum;
- std::string question;
- srand(time(0));
- int passed = 0;
- std::cout << "Guessing Game! Try guessing the Number, from 1-9000\n\n";
- int ranNum = randNumb();
- std::cout << "Guess the Number now! ";
- while (passed!=1) {
- int guNum = guess();
- if (guNum == ranNum) {
- std::cout << "Yes! Thats right!!!\n\n";
- int passed = 1;
- break;
- }
- else if (guNum > ranNum) {
- std::cout << "The guessed number is bigger than the wanted number.\n";
- }
- else {
- std::cout << "The guessed number is smaller than the wanted number.\n";
- }
- }
- system("pause");
- return 0;
- }
- int randNumb() {
- int i = 1 + (rand() % 9);
- return i;
- }
- int guess() {
- int j;
- std::cin >> j;
- return j;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement