Solved programming problem

How to Use Square Root Operator in C.

Source code

#include <stdio.h>

#include<math.h>  ///for using square root you have to use this header file

int main()

{

    int n;

    double ans;

    printf("Please Enter Value: ");

    scanf("%d",&n);

    ans = sqrt(n);

    printf("Square root of %d = %.2lf
",n,ans);

    return 0;

}

Output

Please Enter Value: 5

Square root of 5:2.24

Join the discussion

Add your comment