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

void initialize(int *mem, int num_elements, int init);
void show(int *mem, int num_elements);

int
main()
{
	int	num, init;
	int	*mem;
	

	printf("How big an array would you like? ");
	scanf("%d", &num);
	if ((mem = (int *) malloc(sizeof(int) * num)) == NULL)
	{
		fprintf(stderr, "Unable to allocate memory\n");
		exit(1);
	}

	printf("What would you like the initial value to be? ");
	scanf("%d", &init);

	initialize(mem, num, init);
	show(mem, num);

	free(mem);

	return 0;
}

void
initialize(int *mem, int num_elements, int init)
{
	int	i;

	for (i = 0; i < num_elements; i++)
		*(mem + i) = init++;
}

void
show(int *mem, int num_elements)
{
	int	i;
	puts("The values in the array are: ");
	for (i = 0; i < num_elements; i++)
		printf("mem[%d] = %d\n", i, mem[i]);
}
