How it works...
In this program, the average of several integers is computed via an array. That is, a number of integers whose average is supposed to be computed are assigned to an array and an integer pointer is used to access the array elements. A function named findaverage is defined, to which the integer pointer and the count of the numbers are passed. In the function, an assert is used that ensures that the pointer is not NULL. If the pointer is not NULL, the array elements are accessed through the pointer and their addition is done. After the addition of the numbers, their average is computed. The computed average is then returned to the main function where the average is displayed on the screen. If the pointer is not pointing to the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access