C Language

May 14, 2023

How to use sqrt() function in C Language

Program to use sqrt() function in C language

#include <stdio.h>
#include <math.h>
int main(void)
    double n, s;
    printf("enter a number :");
    scanf("%lf", &n);
    s = sqrt(n);
    printf("square root of %.2lf is %.2lf\n", n, s);
    return 0;


enter a number :16
square root of 16.00 is 4.00

by : Nadeem Khan

Quick Summary:

The sqrt() function computes the square root of a number and in our example code we have entered number 16 and the output in 4