13.

What is the output of the following code?

int x;
int *p;
p = new int;
*p = 14;
x = *p;
*p = 65;
cout << x << ", " << *p << endl;


a.
65, 65 c.14, 14
b.65, 14 d.14, 65

Recommended Answers

All 4 Replies

What is the output of the following code?

int *p;
int x;
x = 76;
p = &x;
*p = 43;
cout << x << ", " << *p << endl;


a.76, 76 c.43, 76
b.76, 43 d.43, 43

what do you think ? Don't you have a compiler ? Whats confusing you ?
So many questions( including yours ) but no answers?

well i am actually confused between two choice in either questions so i want to cross check which answer is right that;s it .. i would appreciate an answer from you just for cross checking..
thank you.

Have a go at working out an answer, and post your reasoning here.

Then we can tell you if your approach is good.

Simply telling you the answer won't help you understand why it is (now), or help you in a similar circumstance later.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.