CJCoding With Joseph
15free / daySign inCreate account

Reference vs Pointer on the Same Counter

A reference ref and a pointer ptr are already declared and both refer to the same count. The program reads one integer from input. Then:
1. add 5 to count using the reference ref
2. multiply count by 2 using the pointer ptr

For the input:
10

the expected output is exactly what is shown in Expected Output.

With an input of -3 the output must be After reference: 2 and After pointer: 4.

Expected Output:

After reference: 15
After pointer: 30

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

Hints2 available
Topics:
Pointers
📥 Auto-Input:
10\n
This input is automatically fed to your program's stdin
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.