CJCoding With Joseph
15free / daySign inCreate account

Add Two Vectors

Write a function add that takes two struct Vec values and returns a new struct Vec whose fields are the component-wise sums. In main, a = {1, 2} and b = {3, 4} are added and the result is printed as x y (see Expected Output).

The function must return a struct Vec by value. There is no trailing newline.

Expected Output:

4 6

= newline. No newline after the last line.

Hints4 available
Topics:
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.