I think you are making assertions you cannot back up.
Your method, OP can enter both numbers at once, and you get a weird tab in a funny spot (user input in bold):
Or OP can press ENTER after every number and get a weird tab in a funny spot:
Both are confusing and distracting to the user, who will rightly ask
why is this tab getting printed here during input?
The one rule you should remember when getting input is this:
The user will always press ENTER after every input prompt.
OP prompts for two items, so you do not know whether he will press ENTER once per number or once for both. Write your code to accept it either way.
If it otherwise matters, then make two prompts:
1 2 3 4 5 6 7
|
cout << "Please enter the first number: ";
cin >> a;
cin.ignore( numeric_limits<streamsize>::max(), '\n' );
cout << "Please enter the second number: ";
cin >> b;
cin.ignore( numeric_limits<streamsize>::max(), '\n' );
|
tl;dr: don't do things that will seem weird to the user and don’t do things that force a user to be present.