subject

A custodial staff person at the College does a peculiar thing at night. There is a corridor with a number of lights controlled by toggle switches. Initially all lights are off. Pressing the switch on a light will turn it on. Pressing it again will turn it off. This staff member walks down a corridor with n light n times. On the ith trip the person only toggles the switches whose position number is divisible by i. When coming back to the initial position, the person does not press any switches. Write a program that determines the state (on or off) of the last light in the corridor after the staff member has made n trips up and down the corridor doing this routineYour program should prompt the user for the number of lights in the corridor, read the number and determine and print the value of the last light. You should print an error message if the user does not enter a positive integer. Use a loop for multiple inputs. The loop should terminate when the user enters 0 for the number of lights.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:30
Aprovides legal protection for something an individual has created
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
Which of the following is not a symptom of chronic fatigue syndrome
Answers: 2
question
Computers and Technology, 24.06.2019 08:00
Can someone work out the answer as it comes up in one of my computer science exams and i don't understand the cryptovariables
Answers: 1
question
Computers and Technology, 24.06.2019 16:30
The database design steps are listed below in the incorrect order. choose the correct order number next to each step. determine the information to be stored in the database. determine the fields needed to record the data determine if there will be any repetition of data entered, and separate the fields into tables to normalize the data. create relationships to connect the tables.
Answers: 3
You know the right answer?
A custodial staff person at the College does a peculiar thing at night. There is a corridor with a n...
Questions
question
Mathematics, 08.12.2020 23:40
question
History, 08.12.2020 23:40
question
Biology, 08.12.2020 23:40
question
English, 08.12.2020 23:40
question
English, 08.12.2020 23:40
Questions on the website: 13722361