[圖解C] Example 803: counter the power by using function

// Example 803: counter the power

#include <stdio.h>
#include <stdlib.h>

int powerV(int, int);

int main()
{
    int b, p, ans;
   
    printf("enter the integer base: ");
    scanf("%d", &b);
    printf("enter the integer power: ");
    scanf("%d", &p);
   
    ans = powerV(b, p);
    printf("the ans = %d\n", ans);
   
    system("pause");
    return 0;
}


int powerV(int base, int power)
{
    int i, pValue=1;
   
    for (i=0; i<power ; i++){
        pValue *= base;
    }
   
    return pValue;
}