Home >Backend Development >C#.Net Tutorial >How to use sqrt in c language?

How to use sqrt in c language?

烟雨青岚
烟雨青岚Original
2020-06-24 15:42:5911048browse

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?

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!

Statement:
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
Previous article:How to debug vc++6.0?Next article:How to debug vc++6.0?