# Library Function Math.h sqrt()

## Library Function Math.h sqrt() in C Language

Library Function Math.h sqrt() function is a mathematical function that is used to calculate the square root  of a number. In C language, to use sqrt( ) we must include math.h header file. Here is the theory of how the library function sqrt() in C is used. ### C Library Function Math.h sqrt()

In C, the `sqrt()` function is used to compute the square root of a number. Square root of a number is a value, which on multiplication by itself, gives the original number.

The `sqrt()` function is declared in the `math.h` header file, so you’ll need to include that in your program in order to use the `sqrt()` function.

Syntax for sqrt( ):

```double sqrt(double x);
```

`sqrt()` function return a double data type as result or as a square root of a number.,

Algorithm:

• Declare an integer variable, as num.
• Use the sqrt() function to pass the num variable as an argument to find the square root.
• Print the result.
• Exit or terminate the program.

## Program 1:

Run
```#include <stdio.h>
#include <math.h>

int main ()
{
double a = 81, sq_rt;

sq_rt = sqrt (a);

printf ("Square root of %.2lf =  %.2lf", a, sq_rt);

return 0;
}

```

### Output:

`Square root of 81.00 =  9.00`

## Program 2:

Run
```#include<stdio.h>
#include<math.h>

int main ()
{

int a = 16, sqr_a;
float b = 12.25, sqr_b;
double c = 1443.76;
sqr_a = sqrt (a);
sqr_b = sqrt (b);

printf ("The square root of %d: %d\n", a, sqr_a);
printf ("The square root of %.2f: %.2f\n", b, sqr_b);
printf ("The square root of %.4lf: %.4lf\n", c, sqrt (c));

return 0;
}

```

### Output:

```The square root of 16: 4
The square root of 12.25: 3.50
The square root of 1443.7600: 37.9968
```

### Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

## Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others