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

熱點內容
app後台源碼 發布:2025-03-14 21:33:34 瀏覽:734
cftp目錄是否存在 發布:2025-03-14 21:32:45 瀏覽:97
我的世界斗羅伺服器電腦網易版 發布:2025-03-14 21:28:33 瀏覽:524
java是甲骨文 發布:2025-03-14 21:21:38 瀏覽:126
柱頂要加密 發布:2025-03-14 21:16:11 瀏覽:853
魔聲藍牙耳機怎麼在安卓顯示電量 發布:2025-03-14 21:15:32 瀏覽:618
智慧易店伺服器地址是啥 發布:2025-03-14 20:57:49 瀏覽:887
小米ID密碼忘記了有什麼危害 發布:2025-03-14 20:45:28 瀏覽:611
大麥路由器怎麼改密碼 發布:2025-03-14 20:35:42 瀏覽:88
資料庫片語 發布:2025-03-14 20:27:21 瀏覽:249