I am new here and this is my first post. I have a question that I can't find on google. I'd be grateful if you could help me. I have written many programs dealing with arrays and wanted to know how can I validate an input. Say I have the following code:
QUESTION: how can I make it so that the user can only input numbers from 5-15 in the array? Thank you so mucu
#include <iostream.h>
int main() { int anArray[5]; int i;
cout <<"Enter 5 numbers to fill the array."; for(i = 0; i < 5; i++) { cout << “anArray[“ << i << “]” << “n”; cin >> anArray[i]; }
for(i = 0; i < 5; i++) { cout <<"Here are the numbers in the array. cout <<"anArray[" << i << "]" << anArray[i] << "n";
} return 0;
}