C언어/C언어 예제

[math.h] tan, tanf, tanl 함수 예제 코드, tangent 계산

언제나휴일 2016. 5. 8. 10:11
반응형

[math.h] tan, tanf, tanl 함수 예제 코드, tangent 계산


//C언어 표준 라이브러리 함수 가이드

//double tan(double x); tangent 계산

//float tanf(float x); tangent 계산

//long double tanl(long double x); tangent 계산

//0, 30, 45, 60, 90도의 tangent

 

#include <math.h>

#include <stdio.h>

 

int main(void)

{

    double radian;

    radian = 0.0;

    printf("%f \n", radian * 180 / 3.141592);

    printf("tan(%f)  = %.30f\n", radian, tan(radian));

    printf("tanf(%f) = %.30f\n", radian, tanf((float)radian));

    printf("tanl(%f) = %.30f\n", radian, tanl(radian));

 

    radian = 30 * 3.141592 / 180;

    printf("%f \n", radian * 180 / 3.141592);

    printf("tan(%f)  = %.30f\n", radian, tan(radian));

    printf("tanf(%f) = %.30f\n", radian, tanf((float)radian));

    printf("tanl(%f) = %.30f\n", radian, tanl(radian));

 

    radian = 45 * 3.141592 / 180;

    printf("%f \n", radian * 180 / 3.141592);

    printf("tan(%f)  = %.30f\n", radian, tan(radian));

    printf("tanf(%f) = %.30f\n", radian, tanf((float)radian));

    printf("tanl(%f) = %.30f\n", radian, tanl(radian));

 

    radian = 60 * 3.141592 / 180;

    printf("%f \n", radian * 180 / 3.141592);

    printf("tan(%f)  = %.30f\n", radian, tan(radian));

    printf("tanf(%f) = %.30f\n", radian, tanf((float)radian));

    printf("tanl(%f) = %.30f\n", radian, tanl(radian));

 

    radian = 90 * 3.141592 / 180;

    printf("%f \n", radian * 180 / 3.141592);

    printf("tan(%f)  = %.30f\n", radian, tan(radian));

    printf("tanf(%f) = %.30f\n", radian, tanf((float)radian));

    printf("tanl(%f) = %.30f\n", radian, tanl(radian));

 

    return 0;

}

 

 

출력

0.000000

tan(0.000000)  = 0.000000000000000000000000000000

tanf(0.000000) = 0.000000000000000000000000000000

tanl(0.000000) = 0.000000000000000000000000000000

30.000000

tan(0.523599)  = 0.577350123947458659934284241899

tanf(0.523599) = 0.577350139617919921875000000000

tanl(0.523599) = 0.577350123947458659934284241899

45.000000

tan(0.785398)  = 0.999999673205156813793337278184

tanf(0.785398) = 0.999999701976776123046875000000

tanl(0.785398) = 0.999999673205156813793337278184

60.000000

tan(1.047197)  = 1.732049936116148325382368966530

tanf(1.047197) = 1.732049942016601562500000000000

tanl(1.047197) = 1.732049936116148325382368966530

90.000000

tan(1.570796)  = 3060023.306952843908220529556274414063

tanf(1.570796) = 3185560.750000000000000000000000000000

tanl(1.570796) = 3060023.306952843908220529556274414063


프로그래밍 언어 및 기술 학습, 무료 동영상 강의 언제나 휴일 티스토리

반응형