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
how to create duplicate link list using C???
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.
Give basis knowledge of web designing ...
what is the significance of static storage class specifier?
Write programs for String Reversal & Palindrome check
What is the code for 3 questions and answer check in VisualBasic.Net?
hi send me sample aptitude papers of cts?
What are the different file extensions involved when programming in C?
What is %lu in c?
regarding pointers concept
about c language
Why can’t we compare structures?
hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell
Write a program which returns the first non repetitive character in the string?
Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?