Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

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..

#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 ? 20 Yes 6 No

More C Interview Questions

What is the difference between abs() and fabs() functions?

How can you read a directory in a C program?

if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0

void main() { int a[]={1,2,3,4,5},i; for(i=0;i<5;i++) printf("%d",a++); getch(); }

Where static variables are stored in memory in c?

What are header files why are they important?

please help me.. how to write a code of this output?? "Enter range number:"10 1 is an odd number 2 is an even numbers 3 in an odd numbers 4 " to 10" "printing all odd numbers:" 1,3,5,7,9 "printing all even numbers:" 2,4,6,8,10 "sum of all odd numbers:25 "sum of all even numbers:30 using a C Programming ARRAY pleas pleas help.. its my project ..please :(

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

program for swapping two strings by using pointers in c language

write a c program that if the given number is prime, and their rearrangement(permute) of that number is also prime. Ex: Input is "197" is prime Output: 791,917,179 is also prime. Please any one tell me tha code for that

how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?

What is the difference between %d and %*d in C

Categories
• C (4668)
• C++ (3542)
• VC++ (653)
• Delphi (566)
• Python Related (3238)
• PHP Related (7341)
• Scala (340)
• R Programming (396)
• Kotlin (184)
• Apache Groovy (39)
• Ruby (245)
• Go Programming Language (139)
• Objective-C (429)
• Programming Languages AllOther (736)