C_C++/C_라이브러리_함수

(C언어) sin, tan: 사인(sine), 탄젠트(tangent) 값을 구한다

고니자니 2023. 2. 28. 11:39
반응형
#include <math.h>
double sin(double x);
double tan(double x);

sin 함수는 사인(sine)값을 계산합니다. 각도는 라디안으로 표시합니다.

tan 함수는 탄젠트 값을 계산합니다. 각도는 라디안으로 표시합니다.

 

참고: cos, sin, tan, acos, asin, atan

 

예제: sin(x)

#include <stdio.h>
#include <math.h>
int main()
{
	double x;

	printf("x\tsin(x)\n");
	for (x = 0; x <= 1.0; x += 0.1)
		printf("%.1f\t%f\n", x, sin(x));

	return 0;
}

sin(x) 값

 

예제: tan(x)

#include <stdio.h>
#include <math.h>
int main()
{
	double x;

	printf("x\ttan(x)\n");
	for (x = 0; x <= 1.0; x += 0.1)
		printf("%.1f\t%f\n", x, tan(x));

	return 0;
}

tan(x) 값

 

예제: cos(x)

#include <stdio.h>
#include <math.h>
int main()
{
	double x;

	printf("x\tcos(x)\n");
	for (x = 0; x <= 1.0; x += 0.1)
		printf("%.1f\t%f\n", x, cos(x));

	return 0;
}

cos(x) 값

728x90
반응형