int table_fill(int a[], int n)
{
int cnt; //Variable for counting values
int r; //Scanf's return value
int next; //Variable for increasing array values
cnt = 0;
while ((r = scanf("%i", &next)) != EOF && cnt < n)
{
if (r == 0)
{
printf("Nonnumeric data entered. Please enter a number.\n");
while (getchar() != '\n')
;
}
else
a[cnt++] = next;
}
if (r == 1)
printf("No more room in array after reading %i values.\n", cnt);
return cnt;
}
void print_table(int a[], int n)
{
int i;
for (i = 0; i < n; i++)
printf("%i\n", a[i]);
}
int sort_table(int a[], int n)
{
void swap(int a[], int i, int min_index);
int i;
int j;
int min;
int min_index;
for (i = 0; i <= n-2; i++)
{
min = a[i];
min_index = i;
for (j = (i + 1); j <= n-1; j++)
{
if (a[j] < min)
{
min = a[j];
min_index = j;
}
}
swap(a, i, min_index);
}
}
void swap(int a[], int i, int min_index)
{
int pos;