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

Show the output from the following program. Assume the address of \"a\" is 0012F

ID: 3830660 • Letter: S

Question

Show the output from the following program. Assume the address of "a" is 0012FF20, "b" is 0012FF40, "c" is 0012FF60, and "d" is 0012FF80.

#include <iostream>
using namespace std;

struct abc
{
    int ax;
    abc *ay;
};

void main()
{
    abc a = { 10, NULL }, b = { 20, &a }, c = { 40, &b }, d = { 80, &c };

    abc *e = &d;

    cout << e->ay->ay->ay << endl;
}

Show the output from the following program. Assume the address of "a" is 0012FF20, "b" is 0012FF40, "c" is 0012FF60, and "d" is 0012FF80.

#include <iostream>
using namespace std;

struct abc
{
    int ax;
    abc *ay;
};

void main()
{
    abc a = { 10, NULL }, b = { 20, &a }, c = { 40, &b }, d = { 80, &c };

    abc *e = &d;

    cout << d.ay->ay << endl;
}

Show the output from the following program. Assume the address of "a[0]" is 0012FF20, "a[1]" is 0012FF40, "a[2]" is 0012FF60, and "first" is 0012FF80.

#include <iostream>
using namespace std;

struct quiz
{
    int n1;
    int n2;
    quiz *n3;
};
void main()
{
    quiz a[3] = { { 1, 2, &a[1] }, { 3, 4, &a[2] }, { 5, 6, &a[0] } };
    quiz *first = &a[2];

    cout << first->n3->n3 << endl;

} //main

Explanation / Answer

1)Output is 0012FF20

Because e points to d , d points to c, c points to b and b points to a
when we do
e->ay->ay->ay we get a's address so its 0012FF20


2)
Output is 0012FF40

Because e points to d , d points to c, c points to b and b points to a
when we do
d.ay->ay we get b's address so its 0012FF40


2) Output is 0012FF40

Because a[0] has a[1] address , a[1] has a[2] address , a[2] has a[0] address
first->n3 gives us a[0] and a[0]->n3 gives us a[1]

Thus we get a[1] address so its 0012FF40


Thanks

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