How to find square root in C program?

October 2016

Among various computer programming languages, C is the most basic and widely used language. It gives maximum efficiency and control to the programmers. The C language can be used for mathematical operations ranging from additions and subtractions to square roots and cube roots, alogn with other polynomial powers that can be created through C programming. If you want to write mathematical programs which involve floating points and so on then you will need access to the mathematics library. To find the square root of a number, you can customize the C script to code the logic by using the sqrt function.


How to find square root in C program?


Here is sample program:

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

int main(void)    
double x = 4.0, result;    

result = sqrt(x);    
printf("The square root of %lf is %lfn", x, result);    
return 0;    

Visit: for a great C program.


Thanks to TECH for this tip on the forum.

Related :

This document entitled « How to find square root in C program? » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.