#include <stdio.h>
//TODO: define a function to evaluate a to the power of b without using predefined functions.
int power(int a, int b)
{
int result = 1;
for(int i = 0; i < b; i++)
{
result = result * a;
}
return result;
}
int main(void) {
//TODO: scan two integer from user, a and b
int m, n;
printf("Please enter integer1: ");
printf("Please enter integer2: ");
//TODO: call the function you defined above and assign a variable to the result
printf("m to the power of n is equal to: %d\n", power
(m
, n
));
//TODO: printout the result
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiAKLy9UT0RPOiBkZWZpbmUgYSBmdW5jdGlvbiB0byBldmFsdWF0ZSBhIHRvIHRoZSBwb3dlciBvZiBiIHdpdGhvdXQgdXNpbmcgcHJlZGVmaW5lZCBmdW5jdGlvbnMuCmludCBwb3dlcihpbnQgYSwgaW50IGIpCnsKCWludCByZXN1bHQgPSAxOwoJCglmb3IoaW50IGkgPSAwOyBpIDwgYjsgaSsrKQoJewoJCXJlc3VsdCA9IHJlc3VsdCAqIGE7Cgl9CgkKCXJldHVybiByZXN1bHQ7Cn0KIAppbnQgbWFpbih2b2lkKSB7CgkvL1RPRE86IHNjYW4gdHdvIGludGVnZXIgZnJvbSB1c2VyLCBhIGFuZCBiCgkKCWludCBtLCBuOwoJcHJpbnRmKCJQbGVhc2UgZW50ZXIgaW50ZWdlcjE6ICIpOwoJc2NhbmYoIiVkIiwgJm0pOwoJCglwcmludGYoIlBsZWFzZSBlbnRlciBpbnRlZ2VyMjogIik7CglzY2FuZigiJWQiLCAmbik7CiAKCS8vVE9ETzogY2FsbCB0aGUgZnVuY3Rpb24geW91IGRlZmluZWQgYWJvdmUgYW5kIGFzc2lnbiBhIHZhcmlhYmxlIHRvIHRoZSByZXN1bHQKCXByaW50ZigibSB0byB0aGUgcG93ZXIgb2YgbiBpcyBlcXVhbCB0bzogJWRcbiIsIHBvd2VyKG0sIG4pKTsKIAoJLy9UT0RPOiBwcmludG91dCB0aGUgcmVzdWx0CiAKCXJldHVybiAwOwp9