Question #6994   Submitted by Answiki on 10/22/2022 at 06:33:39 PM UTC

In which library is the sqrt (square root) function in C?

Answer   Submitted by Answiki on 10/22/2022 at 06:34:43 PM UTC

In C, the sqrt() function calculate the square root. This function is part of the math.h library.

#include <math.h>

Here is a full example:

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

int main()
{
    double x = 25.;
    
    // Display 5.000000
    printf("%f", sqrt(x));
    return 0;
}

2 events in history
Answer by Answiki on 10/22/2022 at 06:34:43 PM

In C, the sqrt() function calculate the square root. This function is part of the math.h library.

#include <math.h>

Here is a full example:

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

int main()
{
    double x = 25.;
    
    // Display 5.000000
    printf("%f", sqrt(x));
    return 0;
}

Question by Answiki 10/22/2022 at 06:33:39 PM
In which library is the sqrt (square root) function in C?
# ID Query URL Count

Icons proudly provided by Friconix.