← Back to Pointers
Question 678
Walk an Array of Prices with Pointer Arithmetic
Walk an Array of Prices with Pointer Arithmetic
The arraypricesand a pointerpto its first element are already declared. Inside the loop, print each item and add it tototal- but reach the elements with*(p + i), not withprices[i].
Expected Output:
Item 0: 4 Item 1: 9 Item 2: 2 Item 3: 7 Item 4: 3 Total: 25
= 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.