This blog is under construction

Sunday, 29 April 2012

tan example in C

Header file:
    math.h

Synopsis:
     double tan(double x);

Description:
     Returns tangent value of x.


tan 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 = tan(deg);
        printf("Result: %lf\n", radian);
        return 0;
  }



  Output:
  jp@jp-VirtualBox:~/cpgms/math$ gcc tan.c -lm
  jp@jp-VirtualBox:~/cpgms/math$ ./a.out
  Enter your input:45
  Result: 0.999204


No comments:

Post a Comment