Nguythang

ln(x+1)

Nov 10th, 2015
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<conio.h>
  4. #include<math.h>
  5.  
  6.  
  7. double f(double x,int k);
  8. main()
  9. {
  10.     float x,s=0;
  11.     int k,n;
  12.     printf("nhap vao so x ");
  13.     scanf("%f",&x);
  14.     printf("nhap vao n= ");
  15.     scanf("%d",&n);
  16.     for (k=1;k<=n;k++)
  17.    
  18.     s+=f(x,k);
  19.     printf("\n gia tri cua bieu thuc %lf",s);
  20.    
  21. }
  22.  
  23. double f(double x,int k)
  24. {
  25.     double s=x;
  26.  
  27.     if(k==0)
  28.     s=x;
  29.     else
  30.     s=pow(x,k)/k;
  31.     k++;
  32.     return s;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment