Im not sure how to include a "checker" to prevent incorrect input pls help :( sorry, just started learning last night forgive me.. How should i do about this, without using if else statement or when should i be using that instead?
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int get_number;
char ch;
cout << "Hey! What is your number 1 OR 2?! :";
cin >> get_number;
switch (get_number)
{
case 1: cout << "You pressed 1/nPress anykey to continue!";
break;
case 2: cout << "You pressed 2/nPress anykey to continue!";
break;
default: cout << "Retry! 1 OR 2?! :";
cin >> get_number;
}
cin.ignore(1, '/n');
cout << "Press any key to continue";
cin.get(ch);
return 0;
}