溫馨提示×

c語言函數pow怎么用

小億
270
2024-01-18 17:18:11
欄目: 編程語言

在C語言中,可以使用pow函數來計算一個數的冪。

pow函數的原型如下:

double pow(double x, double y);

其中,x為底數,y為指數。函數返回x的y次冪的結果。

以下是一個使用pow函數計算一個數的平方的例子:

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

int main() {
    double num, result;
    
    printf("請輸入一個數:");
    scanf("%lf", &num);
    
    result = pow(num, 2);
    
    printf("該數的平方為:%.2lf\n", result);
    
    return 0;
}

在此例中,先從用戶獲取一個數,然后使用pow函數計算該數的平方,并將結果打印輸出。

1
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女