當前位置:首頁 » 編程語言 » 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

熱點內容
vc6編譯操作 發布:2025-08-20 23:16:14 瀏覽:869
時統伺服器搭建 發布:2025-08-20 23:15:58 瀏覽:907
c語言單字元 發布:2025-08-20 23:15:12 瀏覽:70
outlook發送伺服器地址在哪裡 發布:2025-08-20 23:06:13 瀏覽:1000
c語言培訓心得 發布:2025-08-20 23:02:20 瀏覽:46
如何打開raw伺服器鏡像 發布:2025-08-20 22:48:13 瀏覽:76
1分鍾造解壓神器 發布:2025-08-20 22:46:28 瀏覽:378
雲伺服器搭建spark 發布:2025-08-20 22:41:19 瀏覽:36
好用免費雲伺服器 發布:2025-08-20 22:16:44 瀏覽:609
傲慢與偏見ftp 發布:2025-08-20 22:11:15 瀏覽:904