관리 메뉴

프로그램 소스

[math.h] sin, sinf, sinl 함수 예제 코드, sine 계산 본문

C언어/C언어 예제

[math.h] sin, sinf, sinl 함수 예제 코드, sine 계산

Only 프로그램 소스 언제나휴일 2016.05.08 10:09

[math.h] sin, sinf, sinl 함수 예제 코드, sine 계산


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

//double sin(double x); sine 계산

//float sinf(float x); sine 계산

//long double sinl(long double x); sine 계산

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

 

#include <math.h>

#include <stdio.h>

 

int main(void)

{

    double radian;

    radian = 0.0;

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

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

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

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

 

    radian = 30 * 3.141592 / 180;

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

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

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

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

 

    radian = 45 * 3.141592 / 180;

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

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

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

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

 

    radian = 60 * 3.141592 / 180;

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

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

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

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

 

    radian = 90 * 3.141592 / 180;

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

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

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

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

 

    return 0;

}

 

출력

0.000000

sin(0.000000)  = 0.000000000000000000000000000000

sinf(0.000000) = 0.000000000000000000000000000000

sinl(0.000000) = 0.000000000000000000000000000000

30.000000

sin(0.523599)  = 0.499999905662436239239809765422

sinf(0.523599) = 0.499999910593032836914062500000

sinl(0.523599) = 0.499999905662436239239809765422

45.000000

sin(0.785398)  = 0.707106665647094345672485360410

sinf(0.785398) = 0.707106649875640869140625000000

sinl(0.785398) = 0.707106665647094345672485360410

60.000000

sin(1.047197)  = 0.866025294852785898491731586546

sinf(1.047197) = 0.866025328636169433593750000000

sinl(1.047197) = 0.866025294852785898491731586546

90.000000

sin(1.570796)  = 0.999999999999946598272515529970

sinf(1.570796) = 1.000000000000000000000000000000

sinl(1.570796) = 0.999999999999946598272515529970


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

0 Comments
댓글쓰기 폼