# C Program to Find the Square Root of a Number

Program description:- Write a C program to find the square root of a given number.

A square root of a number is a value that, when multiplied by itself, gives the number. Example: 4 × 4 = 16, so a square root of 16 is 4. Note that (−4) × (−4) = 16 too, so −4 is also a square root of 16. The symbol is √ which always means the positive square root.

## Program to find Square Root of a Number in C

``````#include<stdio.h>
#include<math.h>
int main()
{
int number;
double result;

printf("Enter any integer number: ");
scanf("%d",&number);

result = sqrt(number);
printf("Square root value=%.2lf",result);

return 0;
}``````

Output:-

Enter any integer number: 25
Square root value=5.00

Enter any integer number: 30
Square root value=5.48

The sqrt() function is defined in C language to calculate the square root value of a number. It is defined inside “math.h” header file.

Note:- If you are using Linux/Unix and getting error `undefined reference to 'sqrt'` then see this undefined reference to ‘sqrt’ even included math.h header file.

To find square root of a number without using sqrt() function see here.

If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!

Similar Basic C programming examples