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

熱點內容
伺服器改id是什麼 發布:2025-07-01 10:30:03 瀏覽:610
php微信開發教程 發布:2025-07-01 10:28:24 瀏覽:841
訪問學者聯系導師 發布:2025-07-01 10:27:44 瀏覽:984
伺服器端的http地址 發布:2025-07-01 10:04:35 瀏覽:176
php好處 發布:2025-07-01 10:01:45 瀏覽:877
安卓車機什麼屏幕好 發布:2025-07-01 09:46:15 瀏覽:547
編譯原理re不能描述的串 發布:2025-07-01 09:34:24 瀏覽:75
本地電腦怎麼用伺服器ip 發布:2025-07-01 09:10:03 瀏覽:831
有趣的python代碼 發布:2025-07-01 09:10:02 瀏覽:362
威龍奇兵ftp 發布:2025-07-01 09:07:38 瀏覽:694