C sqrt Function

The C sqrt function is one of the Math Functions, which used to find the square root of a number or a specified expression. The syntax of the sqrt in C Programming 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.

/* SQRT in C Programming Example */

#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 1

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.

/* SQRT in C Programming Example */

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

int main()
{
    float number, sqrtValue;

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

 The Square Root Value of 64.00 = 8.0000