C programming assignment (with arrays)
I am new to C and i just learned how to use arrays. I have to complete the task below:
There are 100 doors (numbered 1 through 100) and 100 students
(numbered 1 through 100) waiting in a line. Initially, all the doors are closed. A student numbered x passes through all the doors that are multiples of x (i.e., student numbered x goes to doors x; 2x; 3x; ... ) and changes the status of each door, i.e., opens the door if it is closed and closes the door if it is open. After all the students complete their turns, which doors remain open? Write a C program that mimics this experiment and prints the numbers of the doors that remain open at the end.
I am stuck on how to know which door is in what state. This is what I have now.
If I pasted the code wrong I sincerely apologize and I will try again. As you can see the code isn't fully finished. I think I am on the right track I just can't figure out how to know what happens to which door. Thanks for any help.
for(i=1;i<=100 || k==100;i++)