C Program to find the square root of a number


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


float r = sqrt(n)

Example: How to find the square root of a number in c.

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

int main() {

    int n;
    float r;

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

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

    return 0;
}

Output:

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