Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

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 »

CSC 303: DIGITAL LOGIC AND COMPUTER DESIGN
CSC 219: Programing in C
Lab 9
20 Points
Due Apr 14, 2022
Using loops,
anching and arithmetic instructions
A custodial staff person at the College does a peculiar thing at night. There is a co
idor 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 co
idor 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 co
idor after the staff member has made n trips up and down the co
idor doing this routine
Your program should prompt the user for the number of lights in the co
idor, read the number and determine and print the value of the last light. You should print an e
or 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 Day Apr 18, 2022

Solution

Kshitij answered on Apr 19 2022
83 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