← Back to Pointers
Question 673
Reference vs Pointer on the Same Counter
Reference vs Pointer on the Same Counter
A referencerefand a pointerptrare already declared and both refer to the samecount. The program reads one integer from input. Then: 1. add 5 tocountusing the referenceref2. multiplycountby 2 using the pointerptrFor the input: 10 the expected output is exactly what is shown in Expected Output. With an input of -3 the output must beAfter reference: 2andAfter 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
Sign in to use hintsTopics:
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.