Skip to content

Instantly share code, notes, and snippets.

@mshafae
Last active October 4, 2022 03:38
Show Gist options
  • Save mshafae/450b2211f29cc7cae4735833f96bdedb to your computer and use it in GitHub Desktop.
Save mshafae/450b2211f29cc7cae4735833f96bdedb to your computer and use it in GitHub Desktop.
Loop until a number is entered that matches the criteria.
// Gist https://gist.github.com/450b2211f29cc7cae4735833f96bdedb
#include <iostream>
int main(int argc, char const *argv[]) {
std::cout << "Enter a number between 10 and 20: ";
int input_number{0};
std::cin >> input_number;
while (input_number < 10 || input_number > 20) {
std::cout << "Enter a number between 10 and 20: ";
std::cin >> input_number;
}
std::cout << "Thank you!\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment