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 |
What is the most efficient way to count the number of bits which are set in a value?
Explain is it better to bitshift a value than to multiply by 2?
what is the difference between arrays and linked list
26 Answers MAHINDRA, Tech Mahindra, Wipro,
who is the father of C Language?
20 Answers CTS, UST,
Write a function that will take in a phone number and output all possible alphabetical combinations
to write a program, that finds the minimum total number of shelves, including the initial one, required for this loading process. The packets are named A, B, C, D, E …….. Any numbers of packets with these names could be kept in the shelf, as in this example: [ZZLLAAJKRDFDDUUGGYFYYKK]. All packets are to be loaded on cars. The cars are lined in order, so that the packets could be loaded on them. The cars are also named [A, B, C, D, E,………….].
What is c basic?
How does struct work in c?
What is an arrays?
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
what different between c and c++
write a C code to reverse a string using a recursive function, without swapping or using an extra memory.
9 Answers Motorola, TCS, Wipro,