C Program to Calculate Square Root of a Number

C Program to Calculate Square Root of a Number

How to Calculate Square Root of a Number in C? We can do it by Dividing the Number with itself OR by Powering the Number by 1/2 OR by using Math Modules.

Square Root of a Number in C :



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

int main()
{
double number, squareRoot;

   printf("Enter a number: ");
   scanf("%lf", &number);

   squareRoot = sqrt(number);

   printf("Square root of %lf is: %lf", number, squareRoot);

   return 0;
}


Output :