C exp 函数

C 编程中的 exp 函数是数学函数之一,用于返回 E 的给定值或指定表达式的幂。其中,E 是欧拉数,约等于 2.71828。exp 函数的基本语法如下所示。

double exp(double number);

C exp 函数示例

math exp 函数允许您计算 2.71828 的给定幂。在此程序中,我们将计算相同的值并显示输出。

#include <stdio.h>
#include <math.h>

int main()
{
    printf("\n The Exponential Value of e power 0      = %.4f ", exp(0));
    printf("\n The Exponential Value of e power 1      = %.4f ", exp(1));
    
    printf("\n The Exponential Value of e power 5      = %.4f ", exp(5));
    printf("\n The Exponential Value of e power 6.4    = %.4f ", exp(6.4));
    
    printf("\n The Exponential Value of e power -9.32  = %.4f ", exp(-9.32));  
    printf("\n The Exponential Value of e power -10.34 = %.4f ", exp(-10.34));
  
    return 0;
}
exp function finds exponential value

exp 示例 2

在此 C 编程 示例中,我们允许用户输入自己的值。接下来,程序使用 math exp 函数来计算 E 的用户输入数字的幂。

#include <stdio.h>
#include <math.h> 

int main()
{
    float number, expValue;

    printf(" Please Enter any Numeric Value :  ");
    scanf("%f", &number);
  
    expValue = exp(number);
  
    printf("\n Exponential Value of e power %.2f = %.4f ", number, expValue);
  
    return 0;
}
 Please Enter any Numeric Value :  4.25

 Exponential Value of e power 4.25 = 70.1054