Output freezes compiler, and I don't know why...

I am writing a program to calculate the amount of employees needed per hour based on the amount of customers. There must be at least 3 employees at all times, but also 1 additional employee per 20 customers. I wrote this with arrays and for loops, but after I enter all my values of customers per hour (I have just been using 9, 10, 19, 20, 29, 30.... for number customers) and try to print the results it breaks. I am not sure why.... please help. THANK YOU



#include <iostream>
#include <iomanip>
using namespace std;


int main()
{

// Program to calculate how many employees are needed during the day based on customers

string hours[24] = {"0000-0100", "0100-0200", "0200-0300", "0300-0400", "0400-0500", "0500-0600", "0600-0700", "0700-0800", "0800-0900", "0900-1000", "1000-1100", "1100-1200", "1200-1300", "1300-1400", "1400-1500", "1500-1600", "1600-1700", "1700-1800", "1800-1900", "1900-2000", "2000-2100", "2100-2200", "2200-2300", "2300-2400"};

int customers[24], employees[24],i;

cout << "Workforce Calculator" << endl << endl;

//for loop to gather information and calculate employees
for (i=0; i <= 24; i++)
{

cout << "Please enter the amount of customers for the time period of " << hours[i] << ":" << endl;
cin >> customers[i];
employees[i] = 3 + customers[i] / 20;

}


//for loop to print results
for (i=0; i <= 24; i++)
{

cout << "The amount of employees needed to cover certain time periods is as fallows:"<< endl << endl;
cout << "For the timme period of "<< hours[i] << " you will need " << employees[i] << " employees." << endl;

}

}
for (i=0; i <= 24; i++)

Valid indexes for an array of size 24 are in the range of 0-23. The above should be:

for (i=0; i < 24; i++)
Thank you. I forgot the based-zero
Topic archived. No new replies allowed.