C Program to find square root of a number


In this program, You will learn how to find square root of a number in C.


float r = sqrt(n);


Example: How to find square root of a number in C

Run it Now
#include<stdio.h>
#include<math.h>

int main() {

    int n;
    float r;

    printf("Enter a Number :");
    scanf("%d", &n);

    r = sqrt(n);
    printf("\nSquare root of %d is :%f", n, r);

    return 0;
}

Output:

Enter a Number :16
Square root of 16 is :4.000000