double cos(double x); cosine 계산
float cosf(float x); cosine 계산
long double cosl(long double x); cosine 계산
입력 매개 변수 리스트
x radian
반환 값
cosine 값
사용 예
//C언어 표준 라이브러리 함수 가이드 //double cos(double x); cosine 계산 //float cosf(float x); cosine 계산 //long double cosl(long double x); cosine 계산 //0, 30, 45, 60, 90도의 cosine 값 #include <math.h> #include <stdio.h> int main(void) { double radian; radian = 0.0; printf("%f 도\n", radian * 180 / 3.141592); printf("cos(%f) = %.30f\n", radian, cos(radian)); printf("cosf(%f) = %.30f\n", radian, cosf((float)radian)); printf("cosl(%f) = %.30f\n", radian, cosl(radian)); radian = 30 * 3.141592 / 180; printf("%f 도\n", radian * 180 / 3.141592); printf("cos(%f) = %.30f\n", radian, cos(radian)); printf("cosf(%f) = %.30f\n", radian, cosf((float)radian)); printf("cosl(%f) = %.30f\n", radian, cosl(radian)); radian = 45 * 3.141592 / 180; printf("%f 도\n", radian * 180 / 3.141592); printf("cos(%f) = %.30f\n", radian, cos(radian)); printf("cosf(%f) = %.30f\n", radian, cosf((float)radian)); printf("cosl(%f) = %.30f\n", radian, cosl(radian)); radian = 60 * 3.141592 / 180; printf("%f 도\n", radian * 180 / 3.141592); printf("cos(%f) = %.30f\n", radian, cos(radian)); printf("cosf(%f) = %.30f\n", radian, cosf((float)radian)); printf("cosl(%f) = %.30f\n", radian, cosl(radian)); radian = 90 * 3.141592 / 180; printf("%f 도\n", radian * 180 / 3.141592); printf("cos(%f) = %.30f\n", radian, cos(radian)); printf("cosf(%f) = %.30f\n", radian, cosf((float)radian)); printf("cosl(%f) = %.30f\n", radian, cosl(radian)); return 0; }
출력 0.000000 도 cos(0.000000) = 1.000000000000000000000000000000 cosf(0.000000) = 1.000000000000000000000000000000 cosl(0.000000) = 1.000000000000000000000000000000 30.000000 도 cos(0.523599) = 0.866025458250249569047696240887 cosf(0.523599) = 0.866025447845458984375000000000 cosl(0.523599) = 0.866025458250249569047696240887 45.000000 도 cos(0.785398) = 0.707106896725981814988415408152 cosf(0.785398) = 0.707106888294219970703125000000 cosl(0.785398) = 0.707106896725981814988415408152 60.000000 도 cos(1.047197) = 0.500000188675109646929684004135 cosf(1.047197) = 0.500000178813934326171875000000 cosl(1.047197) = 0.500000188675109646929684004135 90.000000 도 cos(1.570796) = 0.000000326794896538138350772186 cosf(1.570796) = 0.000000313916473260178463533521 cosl(1.570796) = 0.000000326794896538138350772186