
-----------------------------------
Ceevu
Mon May 22, 2006 1:31 am

Using exponents
-----------------------------------
I use the MinGW 4.1 compiler and run in WinXP.

As for the Q:

I'm wondering what notation I would use to write exponents in C?

An example I'm working on is writing a program that calculates the volume of a sphere.  Formula is: 4/3*pi*radius(cubed).


cheers and thanks in advance

-----------------------------------
[Gandalf]
Mon May 22, 2006 1:59 am


-----------------------------------
There is no exponent operator in C or C++, instead you can use the pow() function in math.h.
An example of usage:
#include 
#include 

int main()
{
   printf("%d\n", (int)pow (5.0, 3.0)); //returns 5^3
   return 0;
}

-----------------------------------
Ceevu
Mon May 22, 2006 11:39 am


-----------------------------------
Thanks a lot, Gandalf!
