Page 1 of 1

Problem Description: A school has 100 lockers and 100 students. All lockers are closed on the first day of school. As th

Posted: Fri Jul 08, 2022 6:17 am
by answerhappygod
Problem Description: A school has 100 lockers and 100 students.All lockers are closed on the first day of school. As the studentsenter, the first student, denoted S1, opens every locker. Then thesecond student, S2, begins with the second locker, denoted L2, andcloses every other locker. Student S3 begins with the third lockerand changes every third locker (closes it if it was open, and opensit if it was closed). Student S4 begins with locker L4 and changesevery fourth locker. Student S5 starts with L5 and changes everyfifth locker, and so on, until student S100 changes L100. After allthe students have passed through the building and changed thelockers, which lockers are open? Write a function "main" to findyour answer. The program should display the answer like this:Locker x is open Locker y is open … Locker z is open (Hint: Use anarray of 100 boolean elements, each of which indicates whether alocker is open (true) or closed (false).Initially, all lockers areclosed.)