← Pointers: What They Actually Are

Modify Through a Pointer

medium

This time, actually change x – but only through p, never by writing x on the left side of an =. Add amount to it using *p, then print x’s new value (printing x directly at the end is fine; the requirement is only about how you change it).

This is the write half of the reading you did in the last exercise, and it’s the exact mechanic the next lesson wraps inside a function: a piece of code that doesn’t own a variable directly can still reach in and change it, as long as it has that variable’s address.

Your solution

"Run" uses the sample stdin ("10 5"). "Submit" checks your code against all 3 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution