Advertisement
Guest User

c_taylor_shit

a guest
Apr 18th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. double faktor (double szam)
  5. {
  6. double eredmeny=1;
  7.  
  8. for(;szam>0;--szam)
  9. eredmeny*=szam;
  10.  
  11. return eredmeny;
  12. }
  13. double hatvany (double szam, double hatvany)
  14. {
  15. double eredmeny=szam;
  16.  
  17. for(;hatvany>0;--hatvany)
  18. eredmeny*=szam;
  19.  
  20. return eredmeny;
  21. }
  22. int main()
  23. {
  24. printf("Sinus taylor\n");
  25. double x,n = 0;
  26. printf("kerem az x erteket");
  27. scanf("%lf", &x);
  28. printf("kerem az n erteket");
  29. scanf("%lf", &n);
  30. double szumma = 0;
  31.  
  32. for(int i=0;i<n ;i++)
  33. {
  34. szumma+=(hatvany(-1,i)/faktor(2*i))*hatvany(x,2*i+1);
  35. }
  36. printf("az eredmeny: %f", szumma);
  37.  
  38. scanf("%lf", &n);
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement