The sqrt() function is used in C language to calculate the square root of a non-negative real number; its syntax is "double sqrt(double)". There is no "sqrt (int)" in the sqrt() function, but the return value can be int.
How to use sqrt in c language?
The sqrt() function is used in C language to calculate the square root of a non-negative real number.
Function prototype: The function prototype of the math.h header file in VC6.0 is double sqrt(double);
Explanation: sqrt is Square Root Calculations (square root calculations), through this operation can test the floating point capability of the CPU.
Program example:
#include<math.h> #include<stdio.h> int main(void) { double x=4.0,result; result=sqrt(x);//result*result=x printf("Thesquarerootof%fis%f\n",x,result); return 0; } VC 2008后为重载函数,原型为 float sqrt (float),double sqrt (double),double long sqrt(double long)
Note that there is no sqrt (int), but the return value can be the variable type that needs to be used in the int function
Recommended tutorial: "C language"
The above is the detailed content of How to use sqrt in c language?. For more information, please follow other related articles on the PHP Chinese website!