Question: use irvine library ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! One hundred students are
use irvine library One hundred students are assigned lockers through
The student assigned to locker number opens all lockers
The student assigned to locker number then closes all lockers whose numbers are multiples of
The student assigned to locker number toggles the status of all lockers whose numbers are multiples of
Locker number which is open gets closed,
Locker number which is closed, gets opened
And so on for as many lockers need to be toggled
The student assigned to locker number toggles the status of all lockers whose numbers are multiples of
And so on and on for all students and all lockers
Which lockers will be left open after everyone completes their turns?
Convert this C program into x assembly language and find out!
#include
using namespace std;
In this case we will be using a global array
This is not generally the case for any other variables
element array, all elements initialized to
NOTE: For simplicity, element is unused
int Lockers;
Boolean NOT operation just like the exam question
int NotOperationint x
return x : ;
Student x toggles all lockers xxxx
up to and including locker
void StudentTogglingLockersint x
for int i x; i ; i x
Lockersi NotOperationLockersi;
students walk through and toggle lockers
void ToggleLockers
for int i ; i ; i
StudentTogglingLockersi;
void PrintOpenLockers
for int i ; i ; i
if Lockersi
cout i;
cout ;
cout endl;
int main
ToggleLockers;
PrintOpenLockers;
systemPAUSE;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
