Write a user defined function that receives an integer array and find out average of the elements.
#include
using namespace std;
double func(int arr[], int n)
{
int i,sum=0;
for (i = 0; i < n; i++)
sum=sum+arr[i];
return sum/n;
}
int main()
{
int arr[] = {10, 10, 10};
int n = sizeof(arr) / sizeof(arr[0]);
cout << "avg "<< func(arr, n);
return 0;
}
thistimebd Bangladesh Live online newsportal, education, Lifestyle, Health, Photography, gif image etc.
Make your own name or company name website | contact: thistimebd24@gmail.com
Copyright © 2020-2024 News Portal in Bangladesh - THISTIMEBD.COM. ALL Rights Reserved.