Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

c program to arrange digits in a no in ascending and
descending order

Answer Posted / chand

#include <stdio.h>

int main() {
int num,i=0,size=0,j,temp;
scanf("%d",&num);
int k=num;
while(num>0)
{
int rem;
rem=num%10;
size++;
num/=10;
}
int arr[size];
while(k>0)
{
int rem1;
rem1=k%10;
arr[i]=rem1;
i++;
k/=10;
}
for(i=0;i<size;i++)
{
for(j=i+1;j<size;j++)
{
if(arr[i]>arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}

}
}
for(i=0;i<size;i++)
{
printf("%d ",arr[i]);
}
return 0;
}

Is This Answer Correct ?    22 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is meant by initialization and how we initialize a variable?

1046


What are linked lists in c?

1130


What is pointer to pointer in c with example?

1069


Why can't I perform arithmetic on a void* pointer?

1094


Why void main is used in c?

1049


What is a program flowchart and how does it help in writing a program?

1139


What is a dynamic array in c?

1156


List some of the static data structures in C?

1198


How can I do graphics in c?

1030


List the difference between a While & Do While loops?

1098


What is structure data type in c?

1018


I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.

2367


simple program of graphics and their output display

1994


Explain what’s a signal? Explain what do I use signals for?

1151


Explain what does it mean when a pointer is used in an if statement?

1062