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
There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?
What is the difference between memcpy and memmove?
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)
How can I get back to the interactive keyboard if stdin is redirected?
to find the closest pair
Explain the binary height balanced tree?
Is flag a keyword in c?
write a progrmm in c language take user interface generate table using for loop?
What is c basic?
Explain what is the difference between null and nul?
Why we use int main and void main?
the real constant in c can be expressed in which of the following forms a) fractional form only b) exponential form only c) ascii form only d) both a and b
What is header file in c?
Explain the use of 'auto' keyword
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?