# Input values should always be checked for:

posted Sep 21

Input values should always be checked for what?
Input values should always be checked for the following

1. Appropriate range
2. Reasonableness
3. Division by zero
4. If division is taking place
• ## Appropriate range

In C++ there is a different range for different types of data types. These ranges define the maximum and minimum value that data type can hold. For example, int has range of -2,147,483,648 to 2,147,483,647 and char has range of -128 to 127 by default and Bool has range of true or false, etc.
• ## Reasonableness

Reasonableness is the check if the data is reasonable or not. For example, if data does not match what we expect from a last name field then the data is not reasonable.
• ## Division by zero

Division by zero is undefined. Since division by zero is undefined in mathematics and computer science has a lot of concepts of maths, that is why division by zero is also undefined in computer science.
• ## If division is taking place

You have to make sure if in your statement division is taking place as expected. I know it seems stupid but it can make you scratch your head. C++ is more about data types and more critical language. You have to do whatever you want to do by yourself.
For example, if you divide three by five like this ⅗ then you will end up getting an error. You have to do it like this 3.0/5

Hope this will help.

100 points
7 4