How to find square of Number in C language

In this article, we are going to learn how to find the square root of a number. A square root of a number is a value that, when multiplied by itself, gives the number. We will learn about the sqrt() function which is available in C standard library. The header file required for this function is.

C language sqrt() function


The sqrt() function takes a single argument in double and returns its square root. Let us see our code example to calculate the square root of a number.

syntax of sqrt() function is:

double sqrt(double arg);

Program to find Square Root of a Number in C


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

int main()
{
   double number;
   double result;

   printf("Please enter the number: ");
   scanf("%lf",&number);

   result = sqrt(number);

   printf("The Square root of %d is %.2lf",number , result);

   return 0;
}

Output