← Back to Structs
Question 245
Move a Point with a Pointer
Move a Point with a Pointer
Define a struct type named Point with integer fields x and y. Write a function named move that takes a pointer to a Point plus two integers dx and dy, and adds dx to the point's x and dy to its y. In main, create a Point at (2, 3), call move to shift it by (4, 5), then print the result exactly as: Point: (6, 8) followed by a newline. This introduces passing a struct by pointer so the function can change the original.
Expected Output:
Point: (6, 8)= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Structs
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.