c语言编程中,sinx怎么表示?

Python07

c语言编程中,sinx怎么表示?,第1张

在写C语言的程序时,在开头加上一个头文件math.h即可。

即可直接使用sin(x),特别注意x应该为弧度制,如果不是弧度制需要转化为弧度制。

添加头文件方法:#include<math.h>。

扩展资料:

在C语言家族程序中,头文件被大量使用。一般而言,每个C++/C程序通常由头文件和定义文件组成。头文件作为一种包含功能函数、数据接口声明的载体文件,主要用于保存程序的声明,而定义文件用于保存程序的实现。

C标准函数库(C Standard library)是所有符合标准的头文件(head file)的集合,以及常用的函数库实现程序,例如I/O 输入输出和字符串控制。

不像 COBOL、Fortran 和 PL/I等编程语言,在 C 语言的工作任务里不会包含嵌入的关键字,所以几乎所有的 C 语言程序都是由标准函数库的函数来创建的。

1995年,Normative Addendum 1 (NA1)批准了三个头文件(iso646.h, wchar.h, and wctype.h)增加到C标准函数库中。C99标准增加了六个头文件(complex.h, fenv.h, inttypes.h, stdbool.h, stdint.h, and tgmath.h)。

C11标准中又新增了5个头文件(stdalign.h, stdatomic.h, stdnoreturn.h, threads.h, and uchar.h)。至此,C标准函数库共29个头文件 。

常用的C语言函数库:

<math.h>,<stdio.h>,<stdlib.h>,<time.h>,<string.h>。

使用方法:#include+<函数库名>

参考资料来源:百度百科-C标准函数库

C语言sin()用来计算参数x

的正玄值,然后将结果返回。返回-1

至1

之间的计算结果。

例子:

#include

<math.h>

main(){

double

answer

=

sin(0.5)

printf("sin(0.5)

=

%f\n",

answer)

}

执行

sin(0.5)

=

0.479426

C语言sin():

sin()原型:double

sin(double

x)

sin()角度与弧度:

π=180°

1°=π/180

1(rad)=180/π

角度转弧度:用角度乘以π/180

弧度转角度:用弧度乘以180/π,或者用rtod()函数

扩展资料:

与sin相似的acos函数

函数名:

acos

能:计算并返回arccos(x)值、要求-1<=X<=1

函数与形参类型:

double

acos(x)

double

x

程序例:

#include

<stdio.h>

#include

<math.h>

int

main(void)

{

double

result

double

x

=

0.5

result

=

acos(x)

printf("The

arc

cosine

of

%lf

is

%lf\n",

x,

result)

return

0

}

参考资料:CSDN博客频道-C语言中sin和cos的用法

用法:

doublesin(doublex)

doublecos(doubley)

例:

#include<stdio.h>

#include<math.h>

intmain()

{

intn

doublet

constdoublepi=4.0*atan(1.0)

scanf("%d",&n)

t=(n*pi)*1.0/180

printf("%lf\n",pi)

printf("%lf\n",sin(t))

扩展资料

sinln等函数,sin(pi/2)=1,ln1=0的使用

例:

#include<math.h>

#include<stdio.h>

intmain()

{

doublepi=3.1416

printf("sin(pi/2)=%f\nln1=%f\n",sin(pi/2),log(1.0))

return0

}