Current location - Training Enrollment Network - Mathematics courses - How to use sqrt () in C language?
How to use sqrt () in C language?
Sqrt () in C language means square root function, which calculates the square root of a non-negative real number. The function prototype of math.h header file in VC6.0 is double sqrt(double number). The input parameter of sqrt () function is not allowed to be negative. If the input assignment is used as the parameter of the function, the correct result will not be obtained. Therefore, before calling a function, you should check the input parameters of the function.

Extended data:

The input parameter of sqrt () function must be of type double, and the function return type is of type double, so you must use a variable of type double to receive the return value. When the input data is not of double type, you should use forced type conversion to convert it to double type.

When a function receives a reference value, it should use the. %lf? Otherwise, there will be data errors in input or output, especially in data input, which will directly lead to data errors. This is mainly due to the different ways of storing and reading different types of data.