ENGTECH 1CP3 Lecture 8: Input Validation
Input Validation
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
//while loop
int userInput = 0;
cout << "enter an interger number from 1 to 10 " << endl;
// set up so if user enter right values, it bails out of a while loop using
"break"
while (true)
{
cin >> userInput;
if(1<= userInput <=10) // parameters
{
break;
}
else
{
cout << "Please try again" << endl;
}
}
cout << "You may proceed to the next step " << endl;
system("pause");
return 0;
}
find more resources at oneclass.com
find more resources at oneclass.com