C Program to Find Square Root of a Number using sqrt Function

In this C program we will learn to find square root using sqrt function. We will first take a number as input from user using scanf function then calculate square root of number by calling sqrt function of math.h header file.

Required Knowledge

C program to find square root of a number

#include <stdio.h>
#include <math.h>
int main () {
    double x, result;
    printf("Enter a number\n");
    scanf("%lf", &x);
    result = sqrt(x);
    printf("Square root of %lf = %lf\n", x, result);
    return 0;
Enter a number
Square root of 49.000000 = 7.000000
Enter a number
Square root of 85.453000 = 9.244079
Related Topics
C program to find all roots of quadratic equationp
C program to check whether a number is prime or not
C program to add digits of a number
C program to count number of digits in an integer
C program to find sum of digits of a number using recursion
C program to reverse a number using recursion
C program to calculate power of a number
C program to generate random numbers
C program to convert string to integer
List of all C programs