Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- long int fact(int a);
- /*
- * http://img809.imageshack.us/img809/8760/72225322.png
- */
- int main(int argc, char** argv) {
- int i = 0, x1 = 0, n1 = 0;
- double x = 5.0, n = 5.0, toplam = 51.0;
- double islem = 0.0, kuvvet = 0.0;
- printf("x ve n degerlerini giriniz: ");
- scanf("%d %d",&x1,&n1);
- x = (double) x1;
- n = (double) n1;
- for (i = 1; i <= n; i++) {
- //printf("Toplam = %.2lf \n\n",toplam);
- kuvvet = (double) i;
- islem = pow(-1, kuvvet) * pow(x, kuvvet) / fact(i);
- toplam = toplam + islem;
- }
- printf("\n Toplam = %.2lf \n\n",toplam);
- system("pause");
- return (0);
- }
- long int fact(int a) {
- if (a <= 1) {
- return 1;
- } else {
- a = a * fact(a - 1);
- return a;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement