Square root in C

Solved
olioli19_94 -  
ouchenmoustafa Posted messages 1 Status Member -
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
Configuration: Windows XP Firefox 2.0.0.7

4 answers

  1. mamiemando Posted messages 33228 Registration date   Status Moderator Last intervention   7 942
     
    It is the function
    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
    46
    1. reub
       
      Thank you

      Reub
      0
    2. ouchenmoustafa Posted messages 1 Status Member
       
      Thank you, yes the square root function is already coded in the math library: it is the sqrt function. Therefore, there is no need to code it, but how can we see how it is coded or any tool that programs in the lib?
      0