I'm too tired to go over everything right now. Just study it. I'll answer any questions on it later. You might want to look up the 'switch' statement above all else.
#include <iostream>
using namespace std;
int accident[5];
void getNumAccidents(void) {
int n, count;
cout << "How many accidents were in the North, South, East, West\n"
<< "and Central parts of town, respectively?"
<< endl;
for (n = 0, count = 1; count <= 5; ++n, ++count) {
cout << count << ".\t";
cin >> accident[n];
while (accident[n] < 0) {
cout << "Please enter a valid number. "
cin >> accident[n];
}
}
return;
}
void findLowest(void) {
int min = 0;
for (int i = 1; i < 5; ++i)
if (accident[min] > accident[n])
min = i;
cout << endl;
switch (min) {
case 0:
cout << "The North side of town has the safest driving area with " << accident[min] << " accidents." << endl;
break;
case 1:
cout << "The North side of town has the safest driving area with " << accident[min] << " accidents." << endl;
break;
case 2:
cout << "The North side of town has the safest driving area with " << accident[min] << " accidents." << endl;
break;
case 3:
cout << "The North side of town has the safest driving area with " << accident[min] << " accidents." << endl;
break;
default:
cout << "The Central part of town has the safest driving area with " << accident[min] << " accidents." << endl;
}
return;
}
int main(void) {
getNumAccidents();
findLowest();
return 0;
}