在C语言中,power函数用于计算一个数的幂。
函数原型为:
double pow(double x, double y);参数x是底数,参数y是指数。函数返回x的y次方的结果。
示例代码:
int main() { double base = 2.0; double exponent = 3.0; double result = pow(base, exponent); printf("%f raised to the power of %f is %f\n", base, exponent, result); return 0; }输出结果:
2.000000 raised to the power of 3.000000 is 8.000000在上面的示例中,pow函数计算了2的3次方,得到了8的结果。
提供PHP及ThinkPHP框架的定制开发、代码优化,PHP修改、ThinkPHP修改。
版权声明:除特别声明外,本站所有文章皆是本站原创,转载请以超链接形式注明出处!