how do u compute x^Y without using math function code example
Example 1: Write a Program to find exponential without using pow() method
#include <stdio.h>
int main() {
int base, exp;
long long result = 1;
printf("Enter a base number: ");
scanf("%d", &base);
printf("Enter an exponent: ");
scanf("%d", &exp);
while (exp != 0) {
result *= base;
--exp;
}
printf("Answer = %lld", result);
return 0;
}
Example 2: creating modulu function withou using % java
public static int mod(int x1, int x2) {
int d = x1 / x2 - 1;
int result = x1 - (d * x2);
return result;
}