Sum of integer array – CSKC
Sign In

Search

Solved Problem #CPP#3088    siteicon   siteicon  

Problem Statement - Sum of integer array

Write a program to collect 5 integer values from user in an integer array and then pass this array to a function along with its size. Return the sum of the array members from the function and print its value in the main routine.

Solution

TC++ #3088

 

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test CPP

  Related ( ? ) :

Notes

  • It is important to pass the size of array to a function as array is always passed by a reference. For this reason only the address of first member is passed and there is no way to find array boundary unless the array size is passed. However when strings are passed as reference array boundary can be determined by null termination point and length of string need not be passed.

Common Errors

  • Most common error student do is in understanding that array member filling has to start from 0 and not from 1 but the user has to be asked to fill member number 1, 2 and so on.


Share

Created: 27-Jan-2018 22:04 | Updated: 29-Nov-2018 17:20|