"DO-OVER!" (5th grade kickball)
sorry about the stupid subject but I didnt know what else to use.
In my program I would like the input to be validated as a legitatime number and if its not then I want to see an error and ask to reinput the number.
Code:
Example:
Enter number 1:
4
Integer Valid.
Enter number 2:
5f
Invalid Integer. Please try again.
Enter nuber 2:
-8.8
Integer Valid.
So I really have 2 questions:
1) How can I get a loop to move back up to ask the question again (I hope that makes sense)
and
2) Can someone help me with the validation. It already accepts negative and decimals but I dont know how to get it to post an error if its invalid.
I know its not much, but here is what I have so far.
Code:
double Array[25];
for(int counter = 0; counter < maxnum ; counter++){
cout << "\nEnter number " <<(counter+1) << "\n";
cin >> Array[counter];
cout << "\n";