Zany Zack, Arrays, and Functions.

I have been assigned the following problem:

Zack the Zany (formerly the Employee of the Month) has been reassigned night duty at
Super Club. Zack is back to being easily bored, and has decided to play a little game to
pass the time using the stock of 1000 drink tumblers that the store hasn’t put on sale yet.
Each tumbler also comes with a lid. Here’s how the game works:

1. First Zack goes through and takes the lid off all 1000 tumblers.
2. He then returns to the first tumbler and puts the lid back on every other one.
3. Then he returns to the first tumbler and checks every third one:
If the lid is off, he puts it back on the tumbler.
If the lid is on, he takes it off the tumbler.
4. He repeats the process for every fourth tumbler and lid, every fifth tumbler and lid,
etc.
5. At the end, what tumblers have lids on them?

You must use an array for this assignment and an enumerated type.

This is my program I have written:
#include<iostream>
using namespace std;

void tumbler (int array[], int size){
enum Status{ON, OFF};

//Zack takes off or puts on lids of tumblers divisible by 2, 3, 4, 5, etc.
for (int count = 0; count < size; count ++){ //count for all 1000 tumblers
for (int i = 1; i < size; i ++){ //count for divisiblity
if ( i%count == 0 && array[i] == ON){
array[count] = OFF;
}
else if (i%count == 0 && array[i] == OFF){
array[count] = ON;
}

}

}
cout<<array[size];
}

int main(){
const int size = 1000;
int array[size];
enum Status{ON, OFF};
//Zack takes all the lids off
array[1000] = OFF;
//function call
tumbler(array, size);


return 0;
}

My problem is the program compiles with no errors but as soon as I try to run it, my computer starts complaining. I'm not sure what I'm doing wrong. If someone could offer me a suggestion, that would be great!
First of all, use code tags (the button with <>)
If size is 1000, array has elements from 0 to 999, so array[1000] tries to write after the end of array. In order to take the lids off, you need to write a for loop, and initialize each element to OFF
Please don't cross-post to multiple forums:

http://www.cplusplus.com/forum/beginner/136
Topic archived. No new replies allowed.