在C語言中,可以使用庫函數sqrt來實現開根號計算。c語言中沒有根號。。首先在 main()函數 上邊復加個#include "math.h" 因為開根號制屬于 數學函數里百邊的函數,要使用根號就要加上#inculde "math.h",然后在math.h里封裝好函數double sqrt(double x)。
舉例代碼如下:
#include <math.h> \\ 頭文件:math.h #include <stdio.h> #include <stdlib.h> double sqrt(double x); \\聲明:double sqrt(double x); int main(void) { double x = 3.1415926540, result; result = sqrt(x); \\調用sqrt(x) printf("The square root of %lf is %lf", x, result); return 0; }
回答所涉及的環境:聯想天逸510S、Windows 10。
在C語言中,可以使用庫函數sqrt來實現開根號計算。c語言中沒有根號。。首先在 main()函數 上邊復加個#include "math.h" 因為開根號制屬于 數學函數里百邊的函數,要使用根號就要加上#inculde "math.h",然后在math.h里封裝好函數double sqrt(double x)。
舉例代碼如下:
回答所涉及的環境:聯想天逸510S、Windows 10。