Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <math.h>
- long readnumber ()
- {
- long zahl;
- printf ("Broj: ");
- scanf ("%ld",&zahl);
- return zahl;
- }
- long fakt (long zahl)
- {
- long faktorial=1;
- long i=1;
- if (zahl<0)
- {
- return 0;
- }
- else
- {
- for (i;i<=zahl;i++)
- {
- faktorial*=i;
- }
- return faktorial;
- }
- }
- double my_cosh(double x,long n)
- {
- int i=0,sum=0;
- for (i;i<=n;i++)
- {
- sum+=pow(x,2*i)/faktorial(2*n);
- }
- return sum;
- }
- int main ()
- {
- long zahl,faktorial,a=1;
- double sum,glieder,stelle;
- do
- {
- zahl = readnumber ();
- faktorial = fakt (zahl);
- printf ("Faktorial: %ld\n",faktorial);
- printf ("Glieder: ");
- scanf ("%lf",&glieder);
- printf ("%lf",glieder);
- printf ("Stelle: ");
- scanf ("%lf",&stelle);
- printf ("%lf",stelle);
- sum= my_cosh(stelle,glieder);
- printf ("Tylor: %lf",sum);
- printf ("Weiter?");
- scanf ("%ld",&a);
- }
- while (a=1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement