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: 3830662 • 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 addr
{
    int *ad1;
    int *ad2;
    int *ad3;
};

void main()
{
    int a = 10, b = 20, c = 40, d = 80;

    addr ad4 = { &d, &b, &c };

    cout << ad4.ad3 << 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 addr
{
    int *ad1;
    int *ad2;
    int *ad3;
};

void main()
{
    int a = 10, b = 20, c = 40, d = 80;

    addr ad4 = { &b, &d, &a };

    cout << ad4.ad2 << endl;
}

Explanation / Answer


1)
struct addr
{
int *ad1;
int *ad2;
int *ad3;
};

void main()
{
int a = 10, b = 20, c = 40, d = 80;

addr ad4 = { &d, &b, &c };

cout << ad4.ad3 << endl;
}

"a" is 0012FF20,
"b" is 0012FF40,
"c" is 0012FF60, and
"d" is 0012FF80

Output: 0012FF60 (address of c)

2)
struct addr
{
int *ad1;
int *ad2;
int *ad3;
};

void main()
{
int a = 10, b = 20, c = 40, d = 80;

addr ad4 = { &b, &d, &a };

cout << ad4.ad2 << endl;
}

a" is 0012FF20,
"b" is 0012FF40,
"c" is 0012FF60, and
"d" is 0012FF80

Output: 0012FF80 (address of d)

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