24. a+(a³/3!)+(a⁵/5!)+... :—
#include<stdio.h>
int main()
{
int i,n,a,f,k,sum;
printf("enter value of n and a ");
scanf("%d%d",&n,&a);
sum=0,f=1;
for(i=1;i<=n;i++)
{
k=2*i-1;
sum=sum+pow(a,k)/(float)f;
f=f*(k+1)*(k+2);
}
printf("%d",sum);
return 0;
}
No comments:
Post a Comment