I have this code in C language, but I'm trying to understand it very well. Could someone explain to me how the "int exponent" function works because I don't understand much of the logic. Thank you
Perform a function that raises a number to any exponent.
#include<stdio.h>
#include<math.h>
int exponente();
int main(){
int num;
int ex, res;
printf("Digite un numero cualquiera:");
scanf("%i", &num);
printf("Digite el exponente el cual desea elevar el numero previo:");
scanf("%i", &ex);
res=exponente(num,ex);
printf("\n El numero escogido %i , elevado al exponente escogido es: %i \n", num, res);
system("pause");
return 0;
}
int exponente(int x, int y){
int z=1 , i;
for(i=1; i<=y; i++){
z=z*x;
}
return (z);
}