I need to error check a user input and it must be a value between 0 and 13 whole numbers only. it will be stored in a int variable using the cin function. I dont remember how to do this since i have not taken a c++ course in 3 years. This assignment is using top down progamming, not object oriented programming.

perhaps this will help jog your memory

perhaps this will help jog your memory

I looked at the tutoral and have not seen anything about error checking i think I have the basic concept of c++ I have completed the top down course at my school. I am now enrolled in opject oriented programing class. My first assigment is a review from my last class and my notes on error checking are terrible. that is my fault but i dont have anything to look at to see how to set this one up. any help you can give would be greatly appriciated. I am not sure what this text box means by surround code could you briefly explain this to me as well. this is the first time i have ever posted a thread. thankyou soo much.

when/if you paste any of your code in a reply you need to do it like this

[code.]

\\code goes here

[/code.]

of course, you want to take out the '.' after the word code which makes your reply look like this:

#include <iostream>
...
return 0 ;

etc.


As for the error checking, consider this. If you wanted to check that 'x' is less than 10 but greater than 0, you could use the following construct:

if ( x > 0 && x < 10 )
     cout << "Excellent!" << endl ;
else
{
     cout << "Invalid Input!!  --  Exiting program!!" << endl ;
     exit ( 1 ) ;
}

So now, what else could you check with the if/else statements and how?
Does this help any?

yes i was just going about it from the wrond direction very helpfull thankyou very much for your time and wisdom

welcome. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.