C语言中使用数学函数

  C语言中使用数学函数,例如:exp等

1、包含头文件

  #include <math.h>

2、编辑源码testExp.c,例如:

#include<stdio.h>
#include<math.h>
int main()
{
    double m = 4;                                      //为变量赋初值
    double n = exp(m);                              //求双精度数m的指数函数值
    printf("%lf\n", n);
    return 0;
}        

3、编译时需加上库的链接

  gcc testExp.c -lm  -o testExp

4、执行:

  ./testExp  

  结果:54.598150

  

posted @ 2022-12-27 10:53  叕叒双又  阅读(352)  评论(0编辑  收藏  举报