Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <math.h>
  4.  
  5. long readnumber ()
  6. {
  7. long zahl;
  8. printf ("Broj: ");
  9. scanf ("%ld",&zahl);
  10.  
  11. return zahl;
  12. }
  13.  
  14. long fakt (long zahl)
  15. {
  16.  
  17. long faktorial=1;
  18. long i=1;
  19.  
  20. if (zahl<0)
  21. {
  22.  
  23. return 0;
  24. }
  25. else
  26.  
  27. {
  28.  
  29. for (i;i<=zahl;i++)
  30.  
  31. {
  32. faktorial*=i;
  33. }
  34.  
  35. return faktorial;
  36.  
  37. }
  38.  
  39. }
  40.  
  41. double my_cosh(double x,long n)
  42. {
  43. int i=0,sum=0;
  44.  
  45. for (i;i<=n;i++)
  46. {
  47. sum+=pow(x,2*i)/faktorial(2*n);
  48. }
  49.  
  50. return sum;
  51. }
  52.  
  53. int main ()
  54.  
  55.  
  56. {
  57.  
  58. long zahl,faktorial,a=1;
  59. double sum,glieder,stelle;
  60.  
  61. do
  62. {
  63. zahl = readnumber ();
  64. faktorial = fakt (zahl);
  65. printf ("Faktorial: %ld\n",faktorial);
  66.  
  67. printf ("Glieder: ");
  68. scanf ("%lf",&glieder);
  69. printf ("%lf",glieder);
  70.  
  71. printf ("Stelle: ");
  72. scanf ("%lf",&stelle);
  73. printf ("%lf",stelle);
  74.  
  75.  
  76. sum= my_cosh(stelle,glieder);
  77. printf ("Tylor: %lf",sum);
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86. printf ("Weiter?");
  87. scanf ("%ld",&a);
  88.  
  89. }
  90. while (a=1);
  91. return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement