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 |
how the size of an integer is decided? - is it based on processor or compiler or OS?
19 Answers HCL, JPR, Microsoft, nvidia,
‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.
What is the difference between mpi and openmp?
What is header file in c?
what is the difference b/w NULL and null?
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
How can I implement a delay, or time a users response, with sub-second resolution?
can u write a program in C, which does not use = (eqaul)or any arithmatic assignment(like -=,+=,*= etc) operator to swap to number?
what is out put of the following code? #include class Base { Base() { cout<<"constructor base"; } ~Base() { cout<<"destructor base"; } } class Derived:public Base { Derived() { cout<<"constructor derived"; } ~Derived() { cout<<"destructor derived"; } } void main() { Base *var=new Derived(); delete var; }
Total of how many functions are available in c?
write a c code "if you give a any decimal number then print that number in english alphabet"? ex: i/p: 552 o/p: five hundred fifty two ...
write a c program to change only the 3rd bit of the particular number such that other bits are not affected.. if bitnum=10(say.. it can be any no..