Онлайн компилятор C

#include <stdio.h> int power(int n, int p) { int result = 1; for (int i = 0; i < p; i=i+1) { result *= n;//n累乘i次 } return result; } int main() { int N, P; scanf("%d %d", &N, &P); int result = power(N, P); printf("%d\n", result); return 0; }
1) This code calculates the power of a number (N raised to the power P) using a custom function called `power()`. It takes two integers as input, computes the result using a loop, and prints the output.

2) Hints:  
- The loop in `power()` runs exactly P times, multiplying the result by N each time.  
- Make sure to initialize `result` to 1, as multiplying by 0 would always give 0.