// Iterative raise integer to integer power: // // ---------------------------------------------------- // (c) Copyright 2003 Julian V. Noble. // // Permission is granted by the author to // // use this software for any application pro- // // vided this copyright notice is preserved. // // ---------------------------------------------------- #include #include int power( int i, int j ); // prototypes int main( void ) { int a; int b; printf("What are m and n? "); scanf(" %d", &a); scanf(" %d", &b); printf( " %d\n", power(a,b) ) ; return 0; } int power( int i, int j ) { int k=1; while ( j>0) { if (j & 1) k = i * k; j = j/2; i = i*i; } return k; }