Validation of data

We studied how to get input from user. We can check whether user input value is valid or not. This operation of validating is known as Data Validation. Inputs have to be validated before allowing any kind of processing or operations to be performed on it. This is extremely important because , an unhandled wrong input might have the ability to crash a system. C++ has some good validation techniques that can be used to validate most kind of inputs.

CODE

EG 1 . Validating data of user input.

#include <iostream>
using namespace std;

int main() {
    int number;
    cout << "Enter Number : ";
    if (cin >> number) {
        cout << "It is acceptable value" << endl;
    }
    else {
        cout << "It is unacceptable value" << endl;
    }
}