printf("2 raised to the power of 3 is: %lf", result);
將以上代碼片(pian)段組合在一起,完整的C語(yǔ)言程序如下:
#include <stdio.h>#include <math.h&g(′▽?zhuān)?)t;int main() { int base = 2; int exponent = 3; double result = pow(base, exponent); printf("2 raised to the power of 3 is: %lf", result); return 0;}
#include(?????) <stdio.h>#include <math.h(╯°□°)╯︵ ┻━┻>doヾ(′▽?zhuān)??uble power(int base, int expone(′▽?zhuān)?)nt) { if (exponent == 0) { return 1; } else if (exponent > 0) { return base * power(base, exponent 1); } else { return 1 / power(base, exponent); }}i(′▽?zhuān)?)nt main() { int base = 2; int exponen(╯°□°)╯t = 3; doub??le result = power(base, exponent); printf("2?? raised to the power of 3 is: %lf",?? result); return 0;}