Power
Write the program which takes two numbers a and b and returns the value of ab. For example for a = 3 and b = 4 the result is 34 = 81.
Write the program which takes two numbers a and b and returns the value of ab. For example for a = 3 and b = 4 the result is 34 = 81.
Comments
int atob(int a, int b) { int i, result = 1; for(i=0; i < b; i++) { result *= a; } return result; }
int main() { int a,b; printf("Give a: "); scanf("%d", &a); printf("Give b: "); scanf("%d", &b); printf("a to the power of b = %d", atob(a,b)); return 0; }