exp() 函数定义在 math.h 头文件中。它有助于返回 e 的给定参数的幂。e 的值等于 2.71828。
double exp( double argument ); #where argument should be a double value
exp() 函数接受一个参数。C 语言中的 exp(x) 等于数学表达式 ex。
| 参数 | 描述 | 必需/可选 |
|---|---|---|
| 参数 | 一个双精度浮点值 | 必需 |
exp() 函数的返回值是给定参数的指数值,它应该是一个双精度浮点值。
| 输入 | 返回值 |
|---|---|
| 双精度浮点数值 | 双精度浮点指数值 |
#include <stdio.h>
#include <math.h>
int main() {
double k = 12.0, output;
output = exp(k);
printf("The exponential value of %.2lf = %.2lf", k, output);
return 0;
}
输出
The exponential value of 12.00 = 162754.79
#include <stdio.h>
#include <math.h>
int main () {
double k = 0;
printf("Exponential value of %lf is %lf\n", k, exp(k));
printf("Exponential value of %lf is %lf\n", k+1, exp(k+1));
printf("Exponential value of %lf is %lf\n", k+2, exp(k+2));
return(0);
}
输出
Exponential value of 0.000000 is 1.000000 Exponential value of 1.000000 is 2.718282 Exponential value of 2.000000 is 7.389056