C sqrt function gets the square root of num

Syntax

C sqrt function has the following format.

  • float sqrtf(float num);
  • double sqrt(double num);
  • long double sqrtl(long double num);

C sqrt functions are from header file math.h.

Description

C sqrt functions return the square root of num.

Example

The following code calculates square root by using C sqrt function.


#include <math.h>
#include <stdio.h>
/*w w  w .  ja v a2  s.c om*/
int main(void)
{
   printf("%f", sqrt(16.0));
}

The code above generates the following result.





















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h