Q: Write a C Program to Calculate Square Root of a Positive Number
How To Calculate Square Root of a number in C Programming
We use built-in function sqrt() to calculate square root of a number.

Include Header File math.h for sqrt() function
We must include math.h header file with the help of pre processor directive in the program. sqrt() function is defined in math.h header file.
Source Code for C Program to Find Square root of a number
/*Input a positive number. Find square root of this number */ #include<stdio.h> #include<math.h> int main() { double num; printf("Enter a positive number to find Square Root:"); scanf("%lf",&num); if(num>0) printf("Square root of %.2lf is = %.2lf",num, sqrt(num)); return 0; }
4,096 total views, 1 views today