其他分享
首页 > 其他分享> > C语言中常用的数学函数

C语言中常用的数学函数

作者:互联网

① double exp(double x); (求e的x次幂)

② double pow(double x, double y); (求x的y次幂)

③ double sqrt(double x); (求x的算术平方根)

④ double fabs(double x); (求参数x的绝对值)

⑤ double log(double x); (以自然对数e为底)

⑥ double log10(double x); (以10为底)

⑦ double sin(double x); (x为弧度)

⑧ double cos(double x); (x为弧度)

#include<stdio.h>
#include<math.h>
int main()
{
    printf("e^3=%.3lf\n", exp(3));//e^3
    printf("2.5^3=%.3lf\n", pow(2.5, 3));//2.5^3
    printf("根号下3.5=%.3lf\n", sqrt(3.5));//根号下3.5
    printf("|-14.1|=%.3lf\n", fabs(-14.1));//|-14.1|
    printf("ln13.4=%.3lf\n", log(13.4));//ln13.4
    printf("log(10, 25)=%.3lf\n", log10(25));//log(10, 25)
    printf("sin(1.5)=%.3lf\n", sin(1.5));//sin(1.5), 1.5为弧度
    printf("cos(1.5)=%.3lf\n", cos(1.5));//cos(1.5), 1,5为弧度
    return 0;
}

 

 

标签:1.5,%.,函数,double,C语言,数学,printf,3lf,log
来源: https://blog.csdn.net/weixin_42048463/article/details/114778422