2 Şubat 2016 Salı

C'DE SIN(X) FONKSİYONUNUN MACLAURIN SERİSİ İLE HESAPLANMASI


#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>

int main(){
int N, c = 0, i, Fctrl = 1, y;
float x, z, Sum = 0;

printf("For exit enter the N is 0 or negative number !\n\n");
printf("Enter a number for Nth term(s) calculating : ");
scanf("%d", &N);
if (N < 1){
return 0;
}
printf("Enter the degrees : ");
scanf("%f", &x);

z = (x * M_PI) / 180;

while (c < N){
if (N > 0){
y = (2 * c) + 1;
for (i = 1; i <= y; i++){
Fctrl = Fctrl * i;
}
Sum = Sum + (pow(-1, c) * (pow(z, y) / Fctrl));
c++;
}
else{
break;
}
}
printf("Sinx Nth terms sum is : %f\n", Sum);
system("pause");
return 0;
}

Hiç yorum yok:

Yorum Gönder