Pow() in c
- how to do square root in c
- how to do square root in calculator
- how to do square root in c++
- how to do square root in computer
Write the c program to find the square root of a number...
How to square in c
C library - sqrt() function
The C library sqrt() function of type double accept the variable x(double) as parameter to return the result of square root. The square of a number is obtained by multiplying the number by itself.
Syntax
Following is the syntax of the C library function sqrt() −
double sqrt(double x)Parameters
This function accepts only a single parameters −
x − This is the floating point value.
Return Value
This function returns the square root of x.
Example 1
Following is the C library program that illustrates the usage of sqrt() function.
#include <stdio.h> #include <math.h> int main () { printf("Square root of %lf is %lf\n", 4.0, sqrt(4.0) ); printf("Square root of %lf is %lf\n", 5.0, sqrt(5.0) ); return(0); }Output
On execution of above code, we get the following result −
Square root of 4.000000 is 2.000000 Square root of 5.000000 is 2.236068Example 2
Below the example demonstrate the usage of sqrt() function in a loop.
This program involve the table of square roots ranges between 0-10.
#include <- how to do square root in code
- how to do square root in cpp