ENGTECH 1CP3 Lecture 8: Input Validation

16 views1 pages
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
Unlock document

This preview shows half of the first page of the document.
Unlock all 1 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers