I am a student and am having trouble getting my for statement to work with an array. This is my first time here. Here is what have so far. Any tips would be greatly appreciated.

using namespace std;

void main()
{#include <iostream>

	// Emp is number of employees needed for each hour in the array. 
	// Each value in the array represents the number of customers present at each hour
	// The equation for number of employees is 3 + 1 added for each additional 20 customers
	// Counter variable is Hour
	int Emp=0;
	int Cust [24] = {96,112,45,12,0,24,32,36,196,20,25,200,187,96,34,67,107,224,107,98,19,30,45,60}; // 24 values for each hour of the day

	for (int Hour=1; Hour <= 24; Hour++)
		Emp = Cust/20 + 3;
		if (Cust%20=0) //Modular division tells if Customers is evenly divided 
			Emp = Emp-1;// Any value disvisible by 20- take 1 employee away because three employees can handle the first 20 	

		//cout // need to output the Hour, number of Customers and number of employees needed



line 4: move it up above liine 1

line 13: for (int Hour=1; Hour <= 24; Hour++)

That is wrong. Arrays are numbered from 0 to (and including) 23, so it should be written like this: for (int Hour=0; Hour < 24; Hour++) line 15: Emp = Cust/20 + 3;

Cust is an array, so it can't be divided. Maybe what you want is to index into the array: Emp = Cust[Hour]; line 16 has similar problem as line 15. You can use the mod operator on an array. if( Cust[Hour] % 20 == 0)

Thank you so much Ancient Dragon!! You have no idea how much time I wasted trying to figure this out. This is a great site!! I will work on having the correct format for future postings i.e. code tags.

This question has already been answered. Start a new discussion instead.