Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This question is from ADTs, Data Structures, and Problem Solving with C++. Page

ID: 3620218 • Letter: T

Question

This question is from ADTs, Data Structures, and Problem Solving with C++. Page 138 #2.


Peter the postman became bored one night and, to break the monotony of the night shift, he carries out the following experiment with a row of mailboxes in the post office. These mailboxes were numbered 1 through 150, and beginning with mailbox 2 he opened the doors of all the even-numbered mailboxes, leaving the others closes. Next, beginning with mailbox 3, he went to every third mail box, opening its door if it were closed, and closing it is it were open. Then repeated this procedure every fourth mailbox, then every fifth mailbox and so on. When he finished, he was surprised at the distribution of closed mailboxes. Write a program to determine which mailboxes these were.

In this problem, your program should use the char ‘O’ to indicate the
“opened door” and the char ‘X’ to indicate the “closed door”. Use only pointer variables and dynamically allocated memory for this problem.

Explanation / Answer

#include using namespace std; int main(){ char *c[150]; for(int i=0;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote