What is the code to open the root number in C language?

醉折花枝作酒筹
Release: 2022-01-12 15:46:04
Original
62906 people have browsed it

In C language, the code to open the root sign is "sqrt (floating point value x)"; for example, "sqrt(4.0)" performs the square root operation on 4, and the result is 2. sqrt() is a built-in root operation function in C language. Its operation result is the arithmetic square root of the function variable; this function can neither operate negative values ​​nor output imaginary results.

The operating environment of this tutorial: Windows 7 system, C 17 version, Dell G3 computer.

Add #include in the header file

Then use sqrt, you can use double definition

For example:

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
double sqrt(double n);
int main(void)
{
double x = 3.1415926540, result;
result = sqrt(x);
printf("The square root of %lf is %lf", x, result);
return 0;
}
Copy after login

What is the code to open the root number in C language?

Recommended tutorial: "C#"

The above is the detailed content of What is the code to open the root number in C language?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!