C sqrt Function

The C sqrt function is one of the Math Functions which is used to find the square root of a number or a specified expression. The syntax of the sqrt in this language is

double sqrt(double number);

C sqrt Function Example

The math square root Function allows you to find the square root of a given number. In this program, We are going to find the square root and display the output.

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

int main()
{
    printf("\n The Square Root Value of 0       = %.4f ", sqrt(0));
    printf("\n The Square Root Value of 1       = %.4f ", sqrt(1));
    
    printf("\n The Square Root Value of 125     = %.4f ", sqrt(125));
    printf("\n The Square Root Value of 500.36  = %.4f ", sqrt(500.36));
    
    printf("\n The Square Root Value of -27.32  = %.4f ", sqrt(-27.32));  
    printf("\n The Square Root Value of -90     = %.4f ", sqrt(-90));
  
    return 0;
}
C sqrt function to find the square root Example

C Square root Example 2

In this C Programming example, we are allowing the user to enter their own value. Next, this program uses the sqrt function to find the square root of the user given number.

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

int main()
{
    float number, sqrtValue;

    printf(" Please Enter any Numeric :  ");
    scanf("%f", &number);
  
    sqrtValue = sqrt(number);
  
    printf("\n The Square Root of %.2f = %.4f ", number, sqrtValue);
  
    return 0;
}
 Please Enter any Numeric :  64

 The Square Root of 64.00 = 8.0000