#include <stdio.h>
#include <stdlib.h>

int	*ft_range(int start, int end)
{
	int	*tab;
	int	size;
	int	i;
	int	step;

	if (start <= end)
		size = end - start + 1;
	else
		size = start - end + 1;
	tab = malloc(sizeof(int) * size);
	if (tab == 0)
		return (0);
	if (start <= end)
		step = 1;
	else
		step = -1;
	i = 0;
	while (i < size)
	{
		tab[i] = start + (i * step);
		i++;
	}
	return (tab);
}

int main() {
    int start = 0;
    int end = 9;
    int i = 0;
    int *result = ft_range(start, end);
    while (i < 10)
    {
    printf("%d\n", result[i]);
        i++;
    }
    free (result);
return 0;
}

Embed on website

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