logo CodeStepByStep logo

v1v2p1p2

Language/Type: C++ pointers

The following code C++ uses pointers and produces two lines of output. What is the output?

int v1 = 10;
int v2 = 25;
int* p1 = &v1;
int* p2 = &v2;

*p1 += *p2;
p2 = p1;
*p2 = *p1 + *p2;

cout << v1 << " " << v2 << endl;
cout << *p1 << " " << *p2 << endl;
line 1
line 2

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.