Home > Article > Backend Development > How to use sqrt in c language
Usage of sqrt in c language: first add the [math.h] header file and define floating point type variables; then use sqrt to find the square root of the parameter, and use printf to display the calculation result; finally after debugging and running, Show results.
Usage of sqrt in c language:
1. To use the sqrt function in c language, first The header file math.h needs to be added, as shown in the figure below.
#2. Next, you need to define the variable type that needs to be used in the function in C language. It is generally defined as a Double type variable, as shown in the figure below.
#3. Then you can directly use the sqrt function to find the square root of the parameter variable and assign it to a double type variable, as shown in the figure below.
#4. Finally, the calculation results can be printed and viewed through the Printf function. The code is as shown in the figure below.
#5. After debugging and running, the program compilation result is obtained as shown in the figure below.
Related learning recommendations: C video tutorial
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!