can anyone give me a clue On this C programming solution. I am not getting an out put.
sin(x) = x - x3/3! + x5/5! - x7/7!....
#include <stdio.h>
#include <math.h>
//#include "stdafx.h"
int factorial (int);
int main ()
{
int n, m;
float x,sinx;
printf("input a value for x :");
scanf_s("%f",&x);
//comp_op=sin((double)x);
//printf("computer value: %f",comp_op);
n=1;
sinx=0;
while (n<=4);
{
n =pow(-1,(n-1)*pow(x,(2*(n-1)+1))/factorial(2*(n-1)+1));
sinx +=n;
}
printf("sin%f=%f",x, sin(x));
//scanf_s("%f",&x); return 0;
}
int factorial(int n);
int factorial(int n)
{
int factorial=1;
while(n>0)
{
factorial*=n;
n--;
}
return factorial;
}
Thank you
#include <stdio.h>
#include <math.h>
//#include "stdafx.h"
int factorial (int);
int main ()
{
int n, m;
float x,sinx;
printf("input a value for x :");
scanf_s("%f",&x);
//comp_op=sin((double)x);
//printf("computer value: %f",comp_op);
n=1;
sinx=0;
while (n<=4);
{
n =pow(-1,(n-1)*pow(x,(2*(n-1)+1))/factorial(2*(n-1)+1));
sinx +=n;
}
printf("sin%f=%f",x, sin(x));
//scanf_s("%f",&x); return 0;
}
int factorial(int n);
int factorial(int n)
{
int factorial=1;
while(n>0)
{
factorial*=n;
n--;
}
return factorial;
}
Thank you