#include<stdio.h>
#include<math.h>
int factorial( int );
int main()

    int n;
    double x,i;
    double value, sinx;
    value = sinx = 0.0;

    printf("Enter the value for x and i");
    scanf("%lf %d", &x, &n);
    for( i=1; i<=n; i=i+2)
    {
        value = pow(x,i);
        sinx += (x - value / factorial(i));
    }

    printf("Result - %f", sinx );

    getchar();
    return 0;
}
int factorial( int n )
{
   int j, fact=1;
   for( j=n; j>0; j-- )
     fact = fact * j;

   return fact;
}


#include<stdio.h>
#include<math.h>
int factorial( int );
int main()

    int n;
    double x,i;
    double value, sinx;
    value = sinx = 0.0;

    printf("Enter the value for x and i");
    scanf("%lf %d", &x, &n);
    for( i=1; i<=n; i=i+2)
    {
        value = pow(x,i);
        sinx += (x - value / factorial(i));
    }

    printf("Result - %f", sinx );

    getchar();
    return 0;
}
int factorial( int n )
{
   int j, fact=1;
   for( j=n; j>0; j-- )
     fact = fact * j;

   return fact;
}


#include<stdio.h>
#include<math.h>
int factorial( int );
int main()

    int n;
    double x,i;
    double value, sinx;
    value = sinx = 0.0;

    printf("Enter the value for x and i");
    scanf("%lf %d", &x, &n);
    for( i=1; i<=n; i=i+2)
    {
        value = pow(x,i);
        sinx += (x - value / factorial(i));
    }

    printf("Result - %f", sinx );

    getchar();
    return 0;
}
int factorial( int n )
{
   int j, fact=1;
   for( j=n; j>0; j-- )
     fact = fact * j;

   return fact;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.