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
In c programming, explain how do you insert quote characters (? And ?) Into the output screen?
What are multidimensional arrays?
What are the types of variables in c?
What is the condition that is applied with ?: Operator?
Is array a primitive data type in c?
How can I split up a string into whitespace-separated fields?
explain what is an endless loop?
What is the usage of the pointer in c?
How can you access memory located at a certain address?
What are pointers? What are different types of pointers?
Explain how can you tell whether two strings are the same?
What is an array in c?
What is c preprocessor mean?
For what purpose null pointer used?
What is sorting in c plus plus?