program to sort digit of a given number in c.

/* program to sort digit of a given number in c */


#include<stdio.h>
int main()
{
int num,newnum,i=0,reminder,result=0;
printf(“enter a number”);
scanf(“%d”,&num);
newnum=num;
while(i<=9)
{
while(newnum!=0)
{
reminder=newnum%10;
if(reminder==i)
result=result*10+reminder;
newnum=newnum/10;
}
newnum=num;
i++;
}
printf(“%d”,result);
return 0;
}

2 thoughts on “program to sort digit of a given number in c.

Leave a Reply

Your email address will not be published.