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

Give basis knowledge of web designing ...

0 Answers   HCL,


What is the function of volatile in c language?

0 Answers  


Is it better to use a macro or a function?

0 Answers  


What is the difference between macros and inline functions?

5 Answers   Global Edge, L&T,


Why is main function so important?

0 Answers  


is forign key will be unique key any table or not?

2 Answers  


Explain how are portions of a program disabled in demo versions?

0 Answers  


Explain how do you determine whether to use a stream function or a low-level function?

0 Answers  


If errno contains a nonzero number, is there an error?

0 Answers  


What are qualifiers?

0 Answers  


In the following control structure which is faster? 1.Switch 2.If-else and which consumes more memory?

4 Answers  


How can I find leaf node with smallest level in a binary tree?

1 Answers  


Categories