當前位置:首頁 » 編程語言 » c語言平方根函數

c語言平方根函數

發布時間: 2024-12-01 01:17:40

c語言程序里怎麼開平方

兩種常用的方法。
都需要include <math.h>

1 用sqrt
double sqrt(double n);\
求參數n的平方根

2 用pow
double pow(double n, double e);
計算n的e次冪
這樣
pow(n,0.5);
就是平方根了

明顯 第一種更實用。

㈡ C語言中開平方函數是什麼

1、C語言中求平方根的函數是sqrt
2、實例:
函數原型: double sqrt(double x);和 float sqrt(float x);
頭文件:#include <math.h>
參數說明:x 為要計算平方根的值
返回值:返回 x 平方根
注意事項:如果 x < 0,將會導致 domain error 錯誤。
示例計算200 的平方根值:
#include <math.h>
#include <stdio.h>
int main(){
double root;
root = sqrt(200);
printf("answer is %f\n", root);
return 0;
}

//輸出:answer is 14.142136

熱點內容
數控車床螺紋編程實例 發布:2025-07-01 04:46:27 瀏覽:420
什麼是安卓品牌尖貨 發布:2025-07-01 04:45:50 瀏覽:695
寫入設備緩存 發布:2025-07-01 04:37:35 瀏覽:430
小雞g4怎麼連安卓 發布:2025-07-01 04:37:25 瀏覽:354
黃金線主圖源碼 發布:2025-07-01 04:35:38 瀏覽:296
阿里輕量伺服器有固定IP嗎 發布:2025-07-01 04:30:27 瀏覽:504
電腦什麼配置要合適 發布:2025-07-01 04:24:15 瀏覽:164
哪個安卓恢復工具不要錢 發布:2025-07-01 04:21:54 瀏覽:740
sql加空格 發布:2025-07-01 04:09:38 瀏覽:579
如何關閉ftp防篡改 發布:2025-07-01 04:09:04 瀏覽:90