C语言 <math.h> exp 函数
-
描述
C库函数double exp(double x))返回的e(自然常数)的x次幂。 -
声明
以下是exp函数的声明。double exp(double x)
参数- x - 这是浮点值。
-
返回值
此函数返回e的x次幂。示例以下示例显示exp函数的用法-
尝试一下#include <stdio.h> #include <math.h> int main () { double x = 0; printf("The exponential value of %lf is %lf\n", x, exp(x)); printf("The exponential value of %lf is %lf\n", x+1, exp(x+1)); printf("The exponential value of %lf is %lf\n", x+2, exp(x+2)); return(0); }
让我们编译并运行上面的程序,它将产生以下结果-The exponential value of 0.000000 is 1.000000 The exponential value of 1.000000 is 2.718282 The exponential value of 2.000000 is 7.389056