/*
Write a program to initialize value into 1-D array. Pass the array as argument to a function and
compute the sum of array. The function should return the calculate sum to the calling function.
*/
#include <iostream>
using namespace std;
inline int sum(int One_d[], int size);
int main()
{
int One_d[] = {4,2,1};
cout<<"SUM: " << sum(One_d,3) << endl;
return 0;
}
inline int sum(int One_d[], int size)
{
return One_d[0] + One_d[1] + One_d[2];
}
No comments:
Post a Comment