Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Write a program that reads an array of five integer elements and then calls a function to recursively calculate the product of these elements.
Write a program that reads an array of five integer elements and then calls a function to recursively calculate the product of these elements.
# include & ltstdio.h & gt

int fun(int *a,int n)

{

If(n==0) returns a [0];

Else returns a[n- 1]*fun(a, n-1);

}

int main()

{

int i,sum

int a[5]={ 1,3,5,7,9 };

sum=fun(a,5);

printf("sum=%d\n ",sum);

Returns 0;

}