Pow program using C language

No comments

#include<stdio.h>
#include<math.h>
void boss(float x,int n);
int main()
{
int n;
float x;
printf("enter your value:  ");
scanf("%f", &x);
printf("enter your number:  ");
scanf("%d", &n);

boss(x,n);


}

void boss(float x,int n)
{
int i,j,temp=1;
         float ans=0,y,z=0;
for(i=1;i<=2*n;i+=2)
{
y=pow(x,i);
for(j=1;j<=i;j++)
{
temp=temp*j;
if(j%2==0){temp=(-1)*temp;}
ans=y/temp;}
z=z+ans;

}printf("%f",z);

}

No comments :

Post a Comment