Example 41: Arithmetic Operations

Learn how to perform different arithmetic operations using pointers.

Problem

Write a function that takes in five numbers as parameters along with three pointers. Calculate the sum, product, and average of the five numbers, and store each result in their respective pointers.

Example

Input (n1, n2, n3, n4, n5) Output (Sum, Product, Average)
3, 5, 8, 12, 15 43, 21600, 8
2, 4, 1, -3, 5 9, -120, 1

Try it yourself

Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.

Get hands-on with 1400+ tech skills courses.