C Program to find Square Root of a Number

How to write a C Program to find Square root of a Number using sqrt and without using sqrt function with example?.

C Program to find Square root of a Number

This C Program allows the user to enter any number and then finds the square root of that number using math function sqrt()

/* C Program to find Square root of a Number */
 
#include<stdio.h>
#include<math.h>
 
int main()
{
  	double number, result;
 
 	printf(" \n Please Enter any Number to find Square root : ");
  	scanf("%lf", &number);
  
  	result = sqrt(number);
  
  	printf("\n Square Root a given number %.2lf  =  %.2lf", number, result);
 
  	return 0;
}
C Program to find Square root of a Number 1

C Program to find Square root of a Number without using sqrt

This program uses the math function pow to find the square root of a number. As we all know √number = number½

/* C Program to Calculate Square root of a Number */
 
#include<stdio.h>
#include<math.h>
 
int main()
{
	double number, result;
 
  	printf(" \n Please Enter any Number to find Square root : ");
  	scanf("%lf", &number);
  
  	result = pow(number, 0.5);
  
  	printf("\n Square Root a given number %.2lf  =  %.3lf", number, result);
 
  	return 0;
}
 Please Enter any Number to find Square root : 3

 Square Root a given number 3.00  =  1.73