Write a c program to print the radix sort

Write a c program to print the radix sort. This program will help you to run the execute the program using radix. this is one of the complex sorting programs when compared to other sorting programs, it’s not based on the size of the program.

#include<stdio.h>
int big(int a[], int n)
{
int average = a[0], i;
for(i = 1; i < n; i++)
{
if(average < a[i])
average = a[i];
}
return average;
}
void sort(int a[], int n)
{
int bucket[10][10], count[10];
int i, j, k, remainder, NOP=0, divisor=1, average, pass;
average = big(a, n);
printf("The average element %d\n",average);
while(average > 0)
{
NOP++;
average/=10;
}
for(pass = 0; pass < NOP; pass++)
{
for(i = 0; i < 10; i++)
{
count[i] = 0;
}
for(i = 0; i < n; i++)
{
remainder = (a[i] / divisor) % 10;
bucket[remainder][count[remainder]] = a[i];
count[remainder] += 1;
}
i = 0;
for(k = 0; k < 10; k++)
{
for(j = 0; j < count[k]; j++)
{
a[i] = bucket[k][j];
i++;
}
}
divisor *= 10;
for(i = 0; i < n; i++)
printf("%d ",a[i]);
printf("\n");
}
}
int main()
{
int i, n, a[10];
printf("Enter the number of rows ");
scanf("%d",&n);
printf("Enter the numbers");
for(i = 0; i < n; i++)
{
scanf("%d",&a[i]);
}
sort(a,n);
printf("After sorting ");
for(i = 0; i < n; i++)
printf("%d ",a[i]);
printf("\n");
return 0;
}

Output:

Enter the number of rows 

3

Enter the numbers

34 76 98

The average element 98 34 76 

After sorting 34 76 98