在 C 中使用 pow() 有问题

Having trouble with pow() in C

我目前正在阅读 Stephen Kochan 的在线版本 "Programming in C (3rd Edition)." 其中一项活动涉及计算方程式,

Write a program that evaluates the following expression and displays the results (remember to use exponential format to display the result): (3.31 x 10-8 x 2.01 x 10-7) / (7.16 x 10-6 + 2.01 x 10-8)

当我尝试这样做时,输出总是 0.0000。这是我的代码。

#include <stdio.h>
int main (void) {
float result;
    result = (3.31 * pow(10,-8) * 2.01 * pow(10,-7)) / (7.16 * pow(10,-6) + 2.01 * pow(10, -8));
    printf ("%f", result);
    return 0;
}

如果我做错了什么,请指出。如果您有什么建议,请说出来。

你必须#include <math.h>

另外,改成这样:

printf ("%e\n", result);

你应该也有

double result;

因为pow()returns一个double.