Answer:
The solution code is written in Python:
Explanation:
To ensure only certain type of operation can be applied on a input value, we can check the data type of the input value. For example, we define a function and name it as square which take one input number, num (Line 1).
Before the num can be squared, it goes through a validation mechanism in by setting an if condition (Line 2) to check if the data type of the input number is an integer, int. If so, the num will only be squared otherwise it return an error message (Line 6).
We can test our function by passing value of 5 and "Test" string. We will get program output:
25
Invalid input