Sunday, October 2, 2011

Digital Sort C program Dev C++

 #define MAX 5  
int main()
{
int x=1,i,flag=1,a[MAX],b[MAX],j=0,k;
for(i=0;i<MAX;i++)
{
printf("Enter Number:");
scanf("%d",&a[i]);
}
while(flag)
{
flag=0;
for(i=0;i<=9;i++)
{
for(k=0;k<MAX;k++)
{
if((a[k]/x)%10==i)
{printf("%d %% %d\n",a[k],x);
b[j++]=a[k];
}
if((a[k]/x)%10!=0)
flag=1;
}
}
x*=10;
for(i=0;i<MAX;i++)
{
a[i]=b[i];
printf("%d\n",a[i]);
}
printf("f%d\n",flag);
getch();
j=0;
}
printf("Sorted array is\n");
for(i=0;i<MAX;i++)
{
printf("%d\n",a[i]);
}
getch();
}

No comments:

Post a Comment

Google+ Followers