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)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.