Use C programming cods Define two arrays x and f each of siz

Use C programming cods Define two arrays x and f, each of size 10, to pass the array to a function, named sum. In main define array, pass arrays, print out the array and the results on screen In function sum, take arrays from main and sum the arrays using the formula below: sum = 0.5 Sigma^size-1_i=1 (f_1 + f_i-1)(x_i-1 - x_i)

Solution

#include<stdio.h>
int main()
{
int x[]={1,2,3,4,5,6,7,8,9,0};
int f[]={1,2,3,4,5,6,7,8,9,0};
int s=sum(x,f);
return 0;
}
int sum(int x[],int f[])
{
int sum1=0;
for(int i=0;i<9;i++)
{
sum1=sum1+((f[i]+f[i+1])*(x[i+1]-x[i]));
}
sum1=sum1/2;
return sum1;
}

 Use C programming cods Define two arrays x and f, each of size 10, to pass the array to a function, named sum. In main define array, pass arrays, print out the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site