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 |
Can we use visual studio for c?
When is a null pointer used?
21. #define square(x) x*x main() { int i; i = 64/square(4); printf("%d",i); }
How will you find a duplicate number in a array without negating the nos ?
hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .
0 Answers Aegis, CDAC, Infosys,
What is openmp in c?
What is volatile in c language?
Is null a keyword in c?
find the output of the following program main() { int x=5, *p; p=&x; printf("%d",++*p); }
how to write palindrome program?
How can I determine whether a machines byte order is big-endian or little-endian?
int main() { int i=-1,j=-1;k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d%d%d%d%d",i,j,k,l,m); }