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));
- bool passed = true;
- std::string again;
- std::cout << "Guessing Game! Try guessing the Number, from 1-100\n\n";
- int ranNum = randNumb();
- while (passed) {
- int guNum = guess();
- if (guNum == ranNum) {
- std::cout << "Yes! Thats right!!!\n\n";
- std::cout << "Want to do it again? yes or no.\n";
- std::cin >> again;
- if (again == "yes") {
- int ranNum = randNumb();
- }
- else {
- passed = false;
- }
- }
- 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);
- std::cout << "Guess the Number now!\n";
- return i;
- }
- int guess() {
- int j;
- std::cin >> j;
- return j;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement