Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.16 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "stdlib.h"
  3. //#include "math.h"
  4.  
  5. int factorial(int x);
  6. double mypow(double x,int y);
  7. double sin(double x);
  8. //double arctan(double x);
  9. //float ln(float x);
  10.  
  11. int main() {
  12.  
  13.    double resultsin;
  14.   // double resultarctan;
  15.    resultsin=sin(90);
  16.   // //resultarctan=arctan(1);
  17.    printf("Der Sinus von 90 ist: %.16f\n",resultsin );
  18.   // //printf("Der arctan von 90 ist: %.16f\n",resultarctan );
  19.  
  20.     return 0;
  21. }
  22.  
  23.  
  24. int factorial(int x){
  25.   if (x == 1)
  26.     return (1);
  27.   else
  28.     return (x * factorial(x-1));
  29. }
  30.  
  31. double mypow(double x,int y){ // x-basis ; y-exponent
  32. double a;
  33. if (y==0){
  34.   return 1;
  35. }
  36. else if (y==1){
  37.   return x;
  38. }
  39. else if (y > 0){
  40.   a=x;
  41.   while (y-- > 1) {
  42.     a =a*x;
  43.   }
  44.   return a;
  45. }
  46.   else if(y < 0){
  47.     a=x;
  48.     while (y++ < -1) {
  49.       a = a*x;
  50.     }
  51.     a = 1/a;
  52.     return a;
  53.   }
  54.  
  55. return 0;
  56. }
  57.  
  58.  
  59. double sin(double x)
  60. {
  61.   double erg;
  62.   double k=10;
  63.  
  64.   erg=(mypow(-1,k)) * ((mypow(x,(2*k+1))) / (factorial((2*k+1))));
  65.  
  66. return erg;
  67. }
  68.  
  69. // double arctan(double x){
  70. //   double erg;
  71. //   double k=0;
  72. //
  73. //   erg=mypow(-1,k) * (mypow(x,(2*k+1)))/(2*k+1);
  74. //
  75. //   return erg;
  76. // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement