1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
long factoriel(long x);
void main(void)
{
double sin=0;
double x;
long p;
long n=0;
long factoriel(long x);
printf("quel est le sinus a calculer?\n");
scanf("%lf",&x);
printf("indiquez le nombre d'iteration\n");
scanf("%ld", &p);
while (n<=p)
{
sin=sin+(pow(x,2*n+1)/(factoriel(2*n+1))*pow(-1.0,n));
n=(n+1);
}
printf("le resultat est %lf",sin);
system("pause");
}
long factoriel(long x)
{
if(x>1) return (factoriel(x-1)*x);
else return x;
} |
Partager