RADIX SORT

If you have any queries please leave a message here
Your Message
×





Radix Sort Programming in C

#include<stdio.h>
#include<conio.h>
void main()
{
int a[8], b[8], c[8];
int i, j, k, value, max, temp;
clrscr();
// Input values for sort
for(i=0;i<8;i++)
{
printf("\n Enter the number...");
scanf("%d",&a[i]);
b[i]=a[i];
}
// Find the maximum number among the numbers are inputed
max=a[0];
for(i=1;i<8;i++)
{
if(max < a[i])
{
max=a[i];
}
}
// Radix sort operation
while(max > 0)
{
for(i=0;i<8;i++)
{
c[i]=b[i]%10;
b[i]=b[i]/10;
}
for(i=0;i<7;i++)
{
for(j=i+1;j<8;j++)
{
if(c[i] > c[j])
{
value=a[j];
for(k=j;k>i;k--)
a[k]=a[k-1];
a[i]=value;

value=b[j];
for(k=j;k>i;k--)
b[k]=b[k-1];
b[i]=value;

value=c[j];
for(k=j;k>i;k--)
c[k]=c[k-1];
c[i]=value;
}
}
}
max=max/10;
printf("\n\n\n");
for(i=0;i<8;i++)
printf("\t%d",a[i]);
}
getch();
}



ABOUT US

QuestionSolves.com is an educational website that helps worldwide students in solving computer education related queries.

Also, different software like Visual Studio, SQL Server, Oracle etc. are available to download in different versions.

Moreover, QuestionSolves.com provides solutions to your questions and assignments also.


MORE TOPIC


Windows Command

UNIX Command

IGNOU Assignment Solution

IGNOU Question Paper Solution

Solutions of Different Questions


WHAT WE DO


Website Devlopment

Training

Home Learning

Provide BCA, MCA Projects

Provide Assignment & Question Paper Solution


CONTACT US


Follow Us