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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s