You're probably working with a very old compiler. Check the int size of your compiler.
If you want to deal with a larger number, use a bigger data type like long or double. But even they have their limits. If you want no such limits, you have to implement your own data type or use one that someone else developed. They'll have limits too but it'll be very large.
The following code might work for you
CODE
long power(long a, int b)
{
long c=a;
int n;
if (b != 0 ){
for ( n=b; n>1; n--) c*=a;
}else{
c = 1;
}
return c;
}
and don't forget to write '%ld' instead of '%d' in printf function to output this function's return value.
Look for a file (probably named limits.h or values.h) in your compiler's include folder that says how big the data types are.
This post has been edited by csmanoj: 4 Oct, 2008 - 05:07 AM