Could you tell me what should be the header I have to include in a C code to be possible to use the power function? I mena, I need to use,
whrwCode:pow(x,y)andCode:xare real numbers.Code:y
Thanks.
Could you tell me what should be the header I have to include in a C code to be possible to use the power function? I mena, I need to use,
whrwCode:pow(x,y)andCode:xare real numbers.Code:y
Thanks.
Code:#include <math.h> int main(void) { double x = 10; double y = 3; double z = pow(x, y); return 0; }
If by "real number" you mean a float, then powf() is what you're looking for. pow() operates on doubles, and there's another function for long doubles. Generally you can just use pow(), though, for floats and doubles.
pow*() is in <math.h>. On some systems, you may need to link with the math library to use them; for GCC, add -lm on the command line.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.