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



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

Answer / 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

More C Interview Questions

What is the difference between pure virtual function and virtual function?

0 Answers  


Explain the difference between struct and union.

2 Answers  


Program to swap the any two elements in an array containing N number of elements?

1 Answers   Bosch, Glenwood, Ugam Solutions,


Explain what is wrong with this program statement? Void = 10;

0 Answers  


What is main void in c?

1 Answers  


void main() { int i=5; printf("%d",i++ + ++i); }

21 Answers   ME,


What are control structures? What are the different types?

0 Answers  


Explain how can I write functions that take a variable number of arguments?

0 Answers  


Explain how do you search data in a data file using random access method?

0 Answers  


What is chain pointer in c?

0 Answers  


Why is main function so important?

0 Answers  


What are the basic data types associated with c?

0 Answers  


Categories