CSC 303: DIGITAL LOGIC AND COMPUTER DESIGN CSC 219: Programing in C Lab 9 20 Points Due Apr 14, 2022 Using loops, branching and arithmetic instructions A custodial staff person at the College does a...

1 answer below »
Refer to attached file


CSC 303: DIGITAL LOGIC AND COMPUTER DESIGN CSC 219: Programing in C Lab 9 20 Points Due Apr 14, 2022 Using loops, branching and arithmetic instructions 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 routine Your 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. Possible sample output: Please enter a positive integer. -3 This is not a positive integer. Please try again. Please enter a positive integer. 3 The last bulb is off. Please enter a positive integer. 0 Have a nice day.
Answered Same DayApr 18, 2022

Answer To: CSC 303: DIGITAL LOGIC AND COMPUTER DESIGN CSC 219: Programing in C Lab 9 20 Points Due Apr 14, 2022...

Kshitij answered on Apr 19 2022
99 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here