在C語言中,可以用sqrt()函數(shù)表示根號(hào),參數(shù)類型為double類型,使用前需要先引入頭文件math.h。

興海ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場景,ssl證書未來市場廣闊!成為創(chuàng)新互聯(lián)建站的ssl證書銷售渠道,可以享受市場價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:028-86922220(備注:SSL證書合作)期待與您的合作!
以下列代碼為例:
#includestdio.h
#includemath.h
void main()
{
double i = 9;
printf("%f\n",sqrt(i));
return 0;
}
擴(kuò)展資料:
math.h數(shù)學(xué)函數(shù)庫,一些數(shù)學(xué)計(jì)算的公式的具體實(shí)現(xiàn)是放在math.h里,具體有:
1、double acos(double x) 返回x的反余弦弧度。
2、double asin(double x) 返回x的反正弦弧度。
3、double atan(double x) 返回x的反正切值,以弧度為單位。
4、double atan2(doubly y, double x) 返回y / x的以弧度為單位的反正切值,根據(jù)這兩個(gè)值,以確定正確的象限上的標(biāo)志。
5、double cos(double x) 返回弧度角x的余弦值。
6、double cosh(double x) 返回x的雙曲余弦。
7、double sin(double x) 返回弧度角x的正弦。
8、double sinh(double x) 返回x的雙曲正弦。
9、double tanh(double x) 返回x的雙曲正切。
10、double exp(double x) 返回e值的第x次冪。
11、double log(double x) 返回自然對(duì)數(shù)的x(基準(zhǔn)-E對(duì)數(shù))。
12、double log10(double x) 返回x的常用對(duì)數(shù)(以10為底)。
13、double modf(double x, double *integer) 返回的值是小數(shù)成分(小數(shù)點(diǎn)后的部分),并設(shè)置整數(shù)的整數(shù)部分。
14、double pow(double x, double y) 返回x的y次方。
15、double sqrt(double x) 返回x的平方根。
16、double ceil(double x) 返回大于或等于x的最小整數(shù)值。
17、double fabs(double x) 返回x的絕對(duì)值
18、double floor(double x) 返回的最大整數(shù)值小于或等于x。
19、double fmod(double x, double y) 返回的x除以y的余數(shù)。
參考資料:
math.h函數(shù)庫——百度百科
首先在 main()函數(shù) 上邊加個(gè)#include "math.h" 因?yàn)殚_根號(hào)屬于 數(shù)學(xué)函數(shù)里邊的函數(shù),要使用根號(hào)就要加上#inculde "math.h",\r\n然后在你要開根號(hào)的數(shù)的前邊加個(gè) sqrt,就可以了 \r\n例如\r\n#inculde "math.h"\r\nmain()\r\n{ float a,b;\r\n printf("please input a nuberm:");\r\n scanf("%f",a);\r\n b=sqrt(a);\r\n printf("%f\n",b);\r\n \r\n}這個(gè)程序就是 讓 用戶輸入個(gè)數(shù)字,然后輸出原數(shù)值的開根號(hào)后的結(jié)果
首先在 main()函數(shù) 上邊加個(gè)#include "math.h" 因?yàn)殚_根號(hào)屬于 數(shù)學(xué)函數(shù)里邊的函數(shù),要使用根號(hào)就要加上#inculde "math.h",\r\n然后在你要開根號(hào)的數(shù)的前邊加個(gè) sqrt,就可以了 \r\n例如\r\n#inculde "math.h"\r\nmain()\r\n{ float a,b;\r\n printf("please input a nuberm:");\r\n scanf("%f",a);\r\n b=sqrt(a);\r\n printf("%f\n",b);\r\n \r\n}這個(gè)程序就是 讓 用戶輸入個(gè)數(shù)字,然后輸出原數(shù)值的開根號(hào)后的結(jié)果
當(dāng)前標(biāo)題:c語言函數(shù)根 c語言根號(hào)表達(dá)式
地址分享:http://chinadenli.net/article26/doeoicg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、網(wǎng)站設(shè)計(jì)公司、建站公司、網(wǎng)頁設(shè)計(jì)公司、定制網(wǎng)站、營銷型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
移動(dòng)網(wǎng)站建設(shè)知識(shí)