I'm writing a program which calculates the average rainfall for 12 months. I need to make sure no chars or negative numbers are inputted into my array but I'm not quite sure how to do that.
This is what i have so far. Any suggestions would be appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void getRainfall(double rainfall[]) //parameter list
{
for (int i = 0; i < 12; i++)
{
cout << "Enter rainfall: ";
cin >> rainfall[i];
if (rainfall[i] <= 0)
{
}
}
}