Skip to content

Commit

Permalink
Fixed an issue
Browse files Browse the repository at this point in the history
Fixed the issue of the program proceeding even if one of the choice inputs was invalid which was causing weird results at the end
  • Loading branch information
imsamroy authored Jul 24, 2022
1 parent 7dfc952 commit db7a44d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ int main()
char numChoice, chanceChoice, yesNo;
startNum = 1;

cout << "Welcome to the Number Guessing Game (v1.0.1)!" <<endl;
cout << "Welcome to the Number Guessing Game (v1.0.2)!" <<endl;
cout << "Guess a random number between your selected range within the chances you select to win the game!" <<endl;
cout << endl << "Project by Sampreet Roy (I use Arch Linux BTW)" <<endl <<endl;

Expand Down Expand Up @@ -56,7 +56,8 @@ int main()
}

else {
cout << "Invalid input, please re-run the game with a valid choice";
cout << "Invalid input, please re-run the game with a valid choice" << endl;
return 0;
}

cout << endl << "Chances for the game" <<endl <<endl;
Expand Down Expand Up @@ -90,7 +91,8 @@ int main()
cin >> chanceLimit;
}
else {
cout << "Invalid input, please re-run the game with a valid choice";
cout << "Invalid input, please re-run the game with a valid choice" << endl;
return 0;
}

srand((unsigned) time(0));
Expand Down

0 comments on commit db7a44d

Please sign in to comment.