當前位置:首頁 » 編程語言 » 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-05-16 21:12:29 瀏覽:461
什麼是nodejs前端伺服器 發布:2025-05-16 21:12:17 瀏覽:404
編譯選項立即綁定未定義符號 發布:2025-05-16 20:55:13 瀏覽:905
linuxmysql慢日誌 發布:2025-05-16 20:47:58 瀏覽:270
村兩委有哪些配置 發布:2025-05-16 20:34:47 瀏覽:292
我的世界有什麼伺服器好玩的 發布:2025-05-16 20:28:57 瀏覽:482
c語言按位與運算 發布:2025-05-16 20:24:10 瀏覽:753
蘋果手機如何修改密碼安全 發布:2025-05-16 20:23:34 瀏覽:193
圖片文字識別演算法 發布:2025-05-16 20:21:54 瀏覽:46
校園ftp伺服器 發布:2025-05-16 20:19:38 瀏覽:72