Skip to content

Instantly share code, notes, and snippets.

@gokhanyavas
Created May 16, 2013 05:13
Show Gist options
  • Save gokhanyavas/5589546 to your computer and use it in GitHub Desktop.
Save gokhanyavas/5589546 to your computer and use it in GitHub Desktop.
Bir Açının Kosinüsünü Hesaplayan C Program.
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
double cosinus(double);
int main()
{
double derece,radyan;
printf("Dereceyi giriniz(0 ile 360 araliginda)\n");
scanf("%lf",&derece);
radyan=derece/180*3.141592653; //dereceyi radyana çevirme
printf("cos %g = %.9f\n",derece,cosinus(radyan));
system("pause");
getch();
return 0;
}
//cos(x)=1-x^2/2!+x^4/4!-x^6/6!.....
double cosinus(double radyan)
{
double k=1.0,i,sonuc=1.0,fakt=1,us=1.0;
for(i=2.0;i<40;i+=2.0)
{
k=k*-1;
fakt=fakt*i*(i-1);
us*=radyan*radyan;
sonuc+=k*us/fakt;
}
return sonuc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment