#include <stdio.h>
int main(){
/* declaration and initialize the variable */
int i_basenumber = 0, i_power = 0, i_tmp_base, i_tmp_power;
/* prompt */
printf("Enter the base number: ");
scanf("%d", &i_basenumber);
printf("Enter the power: ");
scanf("%d", &i_power);
/* assignment the base number to tmp variable */
i_tmp_base = i_basenumber;
/* assignment the power number to tmp variable */
i_tmp_power = i_power;
/* calculate the power */
while(i_tmp_power - 1 > 0 ){
i_basenumber = i_tmp_base * i_basenumber;
i_tmp_power--;
}
/* output the result */
printf("The result is: %d\n", i_basenumber);
return 0;
}
计算M的N次方
最新推荐文章于 2022-10-30 19:59:51 发布