← From C to C++: What's New

Increment by Reference

easy

Complete increment so it adds 1 to the int its reference parameter refers to. main reads n, calls increment(n) (note: no &n at the call site – that’s the other giveaway this is a reference, not a pointer), and prints the result.

This is the exact double_value-style out-parameter pattern from Module 2, rewritten with a reference instead of a pointer – same effect on the caller’s variable, no dereferencing required to get there.

Your solution

"Run" uses the sample stdin ("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