write a program to arrange the contents of a 1D array in
ascending order
Answer Posted / poornima
int main()
{
int a[20],n,i,j,temp;
printf("Enter the size of an array : ");
scanf("%d",&n);
printf("Enter the array elements : ");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[j];
a[j]=a[i];
a[i]=temp;
}
}
}
printf("\nAscending Order\n");
for(i=0;i<n;i++)
{
printf("%d\n",a[i]);
}
return 0;
}
Is This Answer Correct ? | 65 Yes | 22 No |
Post New Answer View All Answers
Calculate 1*2*3*____*n using recursive function??
What is structure in c language?
write a program to input 10 strings and compare without using strcmp() function. If the character of one string matches with the characters of another string , sort them and make it a single string ??? example:- str1="Aakash" st2="Himanshu" str="Uday" output:- Aakashimanshuday (please post the answer as quickly as possible)
What is NULL pointer?
What is formal argument?
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
What is the difference between void main and main in c?
What is the difference between union and anonymous union?
What is the purpose of sprintf() function?
What is the process to create increment and decrement stamen in c?
Write a program on swapping (100, 50)
Explain the term printf() and scanf() used in c language?
Write a C Program That Will Count The Number Of Even And Odd Integers In A Set using while loop
Explain what’s a signal? Explain what do I use signals for?
Can you please explain the scope of static variables?