Check for an integer, fail if anything else
I'm working on an integration program, that works out the integation by approximating with the rectangle rule.
I am trying to ask how many strips do you want? This MUST be an integer, yet if i enter a float, it will work. Is there a way of checking? i have looked but it seems that this integer check business is not as simple a check as it could be.
just need some code that will say
Code:
********* code*********
cout << "Please enter the number of strips: ";
cin >> n;
is n an integer?
no - please retry
yes, carry on........
*********code*********