View Full Version : C/C++ Programming
pacificboy
27-02-2008, 09:46 PM
Related to pow() function in C/C++. The Syntax is : pow(x,y). If the y part of the function is a fraction it gives an error. What should be the Syntax for such a function that there is no error?
QwertyManiac
27-02-2008, 10:18 PM
Pow(x,y) has always worked perfectly for me with fractional y.
Does this program give you an error? Doesn't for me.
#include<math.h>
#include<stdio.h>
int main(void)
{
(void)printf("%f\n",pow(4,0.75));
return 0;
}
Note: If using GCC to compile, do link the math.h by passing -lm parameter.
khattam_
28-02-2008, 03:43 AM
The return is double.. so make sure you use double for the variable...
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.