#include <unistd.h>
#include <stdio.h>

int	ft_iterative_power(int nb, int power)
{
	int	i;
	int	result;

	i = 1;
	result = 1;
	if (power < 0)
		return (0);
	if (power == 0)
		return (1);
	while (i <= power)
	{
		result = result * nb;
		i++;
	}
	return (result);
}

int	main(void)
{
	printf("%d\n", ft_iterative_power(5, 3));
	return (0);
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: