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 are the advantages of using linked list for tree construction?

1024


can anyone please tell about the nested interrupts?

2063


What is calloc()?

1023


What is void main () in c?

1150


Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

1046


How can I read in an object file and jump to locations in it?

982


What is a ternary operator in c?

1053


What do you mean by c what are the main characteristics of c language?

976


What is volatile variable how do you declare it?

1024


Differentiate between new and malloc(), delete and free() ?

1131


HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????

2633


How do you convert strings to numbers in C?

1166


Tell me what is the purpose of 'register' keyword in c language?

968


What are the benefits of organizational structure?

972


Explain what is the advantage of a random access file?

1066