Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include "stdlib.h"
- //#include "math.h"
- int factorial(int x);
- double mypow(double x,int y);
- double sin(double x);
- //double arctan(double x);
- //float ln(float x);
- int main() {
- double resultsin;
- // double resultarctan;
- resultsin=sin(90);
- // //resultarctan=arctan(1);
- printf("Der Sinus von 90 ist: %.16f\n",resultsin );
- // //printf("Der arctan von 90 ist: %.16f\n",resultarctan );
- return 0;
- }
- int factorial(int x){
- if (x == 1)
- return (1);
- else
- return (x * factorial(x-1));
- }
- double mypow(double x,int y){ // x-basis ; y-exponent
- double a;
- if (y==0){
- return 1;
- }
- else if (y==1){
- return x;
- }
- else if (y > 0){
- a=x;
- while (y-- > 1) {
- a =a*x;
- }
- return a;
- }
- else if(y < 0){
- a=x;
- while (y++ < -1) {
- a = a*x;
- }
- a = 1/a;
- return a;
- }
- return 0;
- }
- double sin(double x)
- {
- double erg;
- double k=10;
- erg=(mypow(-1,k)) * ((mypow(x,(2*k+1))) / (factorial((2*k+1))));
- return erg;
- }
- // double arctan(double x){
- // double erg;
- // double k=0;
- //
- // erg=mypow(-1,k) * (mypow(x,(2*k+1)))/(2*k+1);
- //
- // return erg;
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement