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

C++ MyProgrammingLab problem: Given a struct type Employee with members string n

ID: 3563167 • Letter: C

Question

C++ MyProgrammingLab problem:

Given a struct type  Employee with members
string  name   and
Employee * supervisor,
implement the function
void printSupervisors(const Employee & e);
the prints the name of e's supervisor, the supervisor's supervisor and so on.
The chain stops when the supervisor value is NULL.

Your function is called on some employee in the chain Mike --> Sue --> Bob --> Ann --> Juan.
For example if the input is 0 (for Mike) then the output should be Sue Bob Ann Juan.
If the input is 4 (for Juan) there will be no output since Juan has no supervisor.

Do not write the entire program and do not create any other functions.

Explanation / Answer

Given a struct type Employee with members
string name   and
Employee * supervisor,
// implement the function
// the prints the name of e's supervisor, the supervisor's supervisor and so on.
// The chain stops when the supervisor value is NULL.
void printSupervisors(const Employee & e){
Employee* local = &e;
while(loal->supervisor!=NULL)
{
cout << local->supervisor->name << " "
local = local->supervisor;
}
}


Your function is called on some employee in the chain Mike --> Sue --> Bob --> Ann --> Juan.
For example if the input is 0 (for Mike) then the output should be Sue Bob Ann Juan.
If the input is 4 (for Juan) there will be no output since Juan has no supervisor.

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