How do you use the pow function from math.h?

  • Thread starter Thread starter tandoorichicken
  • Start date Start date
  • Tags Tags
    Function
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 25K views
tandoorichicken
Messages
245
Reaction score
0
How do you use the pow function from math.h?
Here's how I've been using it and the compiler gives me trouble:
month_pay = price*i*pow(1.0 + i, (double)n);

This is the way it was written on the handout from our professor but he makes a lot of typos, so I want to make sure if this is the right way to use pow or not.
 
Physics news on Phys.org
It shouldn't take more than a minute or two to run a short test program through your compiler to find out!

You should have no problem demonstrating that pow(a, b) is equivalent to a^b.
 
well, if you are using gcc I believe you must use the -lm option when compiling...AND include math.h

so you must do:
gcc -lm filename.c