Non-integer data in Integer Variable

Q7. Assume that X has been declared as an integer variable in a C++ program. What will happen if the program encounters non-integer data while reading the value of X? How can the situation be rectified?

Ans. If non-integer data (say a string) is given for integer variable the “Type Error” occurs. The situation can be rectified by either retyping the data in integer form or by converting the non-integer data into integer form.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: