Pointers 215
Sz = sizeof(int) *N ; /* Compute the size of the list */
/* Allocate dynamic array size N */
list = (int*) malloc (Sz);
printf (“\n Enter the list”);
/* Read the list */
for (i = 0; i < N; i++)
{
printf (“\n Enter Number:”);
scanf (“%d”, (list + i));
}
pos = 0; /* Assume that the zeroth element is min */
min = *(list + 0);
/* Find the minimum */
for (i = 1; i < N; i++)
{
if (min > *(list + i))
{min = *(list + i);
pos = i;
}
} /* Print the minimum and its location */
printf (“\n The minimum is = %d at position = %d“, min, pos);
free (list);
}
From the above example, ...