CJCoding With Joseph
15free / daySign inCreate account

main is already written:

int a = 5, b = 5, c = 5; addByValue(a); addByReference(b); addByPointer(&c);

Fill in the bodies of addByValue(int n), addByReference(int &n) and addByPointer(int *n) so each one adds 100 to the number it was handed. main then prints the three variables.

The program must print exactly these three lines (see Expected Output).

Expected output

value: 5
reference: 105
pointer: 105

= newline. The output ends with a newline, so print one after the last line.

Hints2 available
Topics
Pointers
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.