I want to do an exponent calculation in C. I tried **, but compiler threw an error.
Is there such operator in C? If not, how to calculate exponent?
I want to do an exponent calculation in C. I tried **, but compiler threw an error.
Is there such operator in C? If not, how to calculate exponent?
No, there isn't such operator in C. There are functions for this: pow(), powf(), powl() (respectively for double, float and long double) defined in header math.h
First parameter is base, second exponent.
Of course, them being defined for floating point types, doesn't mean you cannot use them for integers.
int x = pow(10, 2);
The result of pow() will be properly cast from 100.0 to 100 and assigned to integer variable x