This blog is under construction

Sunday, 29 April 2012

sin example in C

Header file:
    math.h

Synopsis:
     double sin(double x);

Description:
     Returns sin of x.



sin function in C example:


   #include<stdio.h>
  #include<math.h>
  
  int main() {
        /*
         * degree to radian conversion
         * radian = degree * PI/180;
         */
        double deg, radian;
        printf("Enter your input:");
        scanf("%lf", &deg);
        deg = deg * (3.14 / 180);
        radian = sin(deg);
        printf("Result: %lf\n", radian);
        return 0;
  }




  Output:
  jp@jp-VirtualBox:~/cpgms/math$ gcc sin.c -lm
  jp@jp-VirtualBox:~/cpgms/math$ ./a.out
  Enter your input:90
  Result: 1.000000


No comments:

Post a Comment