Square root in C
Solved
olioli19_94
-
ouchenmoustafa Posted messages 1 Status Membre -
ouchenmoustafa Posted messages 1 Status Membre -
Hello,
I have a science assignment to submit on calculating the dew point, so I started working on a mini program that calculates the dew point using atmospheric pressure, temperature, and relative humidity.
To do this, I need to apply this formula: http://upload.wikimedia.org/math/b/0/2/b0224c70ff9310faf366e565cd169b01.png
But I don't know how to do a square root (eighth root but 3 times the square root, it's the same) in C. I've found a lot of code on the internet, but I'm looking for just the function that allows me to store the answer in a variable.
If you don't understand, contact me,
This is really important, as this work counts for 30% of my grade for the stage.
Thank you
Olivier
I have a science assignment to submit on calculating the dew point, so I started working on a mini program that calculates the dew point using atmospheric pressure, temperature, and relative humidity.
To do this, I need to apply this formula: http://upload.wikimedia.org/math/b/0/2/b0224c70ff9310faf366e565cd169b01.png
But I don't know how to do a square root (eighth root but 3 times the square root, it's the same) in C. I've found a lot of code on the internet, but I'm looking for just the function that allows me to store the answer in a variable.
If you don't understand, contact me,
This is really important, as this work counts for 30% of my grade for the stage.
Thank you
Olivier
Configuration: Windows XP Firefox 2.0.0.7
4 réponses
It is the function
http://www.manpagez.com/missing.php
Example:
To compile, remember to link with the math library (
Good luck
sqrt:
http://www.manpagez.com/missing.php
Example:
#include <math.h> #include <stdio.h> int main(){ int x = 69; printf("%d => %lf\n",x,sqrt(x)); return 0; } To compile, remember to link with the math library (
libm). On Linux, with
gcc, this means adding the option
-lm:
(mando@polgara) (~) $ gcc -lm -W -Wall plop.c
(mando@polgara) (~) $ ./a.out
69 => 8.306624
Good luck
Reub