Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. long int fact(int a);
  5.  
  6. /*
  7.  * http://img809.imageshack.us/img809/8760/72225322.png
  8.  */
  9. int main(int argc, char** argv) {
  10.  
  11.     int i = 0, x1 = 0, n1 = 0;
  12.     double x = 5.0, n = 5.0, toplam = 51.0;
  13.     double islem = 0.0, kuvvet = 0.0;
  14.  
  15.     printf("x ve n degerlerini giriniz: ");
  16.     scanf("%d %d",&x1,&n1);
  17.     x = (double) x1;
  18.     n = (double) n1;
  19.  
  20.     for (i = 1; i <= n; i++) {
  21.         //printf("Toplam = %.2lf \n\n",toplam);
  22.         kuvvet = (double) i;
  23.         islem = pow(-1, kuvvet) * pow(x, kuvvet) / fact(i);
  24.         toplam = toplam + islem;
  25.     }
  26.  
  27.     printf("\n    Toplam = %.2lf \n\n",toplam);
  28.     system("pause");
  29.     return (0);
  30. }
  31.  
  32. long int fact(int a) {
  33.     if (a <= 1) {
  34.         return 1;
  35.     } else {
  36.         a = a * fact(a - 1);
  37.         return a;
  38.     }
  39. }