Guest User

Untitled

a guest
Dec 16th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. int num1 = 0;
  2. cin >> num1;
  3.  
  4. while (cin.fail()) {
  5. cout << "Enter a valid number for num1";
  6. cin.clear();
  7. cin.ignore(256, 'n');
  8. cin >> num;
  9. }
  10.  
  11. int num2 = 0;
  12. cin >> num2;
  13.  
  14. while (cin.fail()) {
  15. cout << "Enter a valid number for num2 ";
  16. cin.clear();
  17. cin.ignore(256, 'n');
  18. cin >> num;
  19. }
Add Comment
Please, Sign In to add comment