Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main() {
- int guess = rand() % (100 + 1);
- int input_var = 0;
- do {
- cout << "Enter a number (-1 = quit):";
- if (!(cin >> input_var)) {
- cout << "You entered a non-numeric. Exiting..." <<endl;
- break;
- }
- if (input_var != -1) {
- cout << " You entered " << input_var << endl;
- }
- if (input_var > guess) {
- cout << "that's too high" << endl;
- }
- else (input_var < guess) {
- cout << "that's too low" << endl;
- }
- cout << "that's right" << endl;
- } while input_var != guess
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement