Radix sort program in c for beginners. 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

## Radix Sort in C

Radix sort is an integer sorting technique that groups integer keys by individual digits with the same significant position and value to sort data containing integer keys.

To sort an array of numbers, Radix sort employs counting sort as a function.

Integers are sorted using the radix sort algorithm, which is a linear sorting technique.

Radix sort is a digit-by-digit sorting method that starts with the least significant digit and progresses to the most significant digit.

The radix sorting process is comparable to arranging students’ names alphabetically.

## For Loop Definition in C

A for loop is a repetition control structure that allows us to create a loop that runs a set number of times.

The loop allows us to do an arbitrary number of steps in a single line.

A for loop is a loop that repeats itself for a specified number of times.

A while loop is one that repeats itself as long as an expression is true.

A statement with a value is called an expression.

A do while loop, also known as a repeat until loop, repeats an expression until it turns false.

## Return Statement in C

A return statement marks the end of a function’s execution and hands control back to the calling function.

The calling function continues execution at the place where the call was made.

A return statement can give the caller function a value.

A value can be returned by a function.

The data type of the value returned by the function is the return type.

Some functions do what they’re supposed to do yet don’t return a value.

The keyword void is used as the return type in this scenario.

You pass a value to the parameter when you call a function.

Using this program we can execute radix sort program in c.