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
All technical questions
What is structure padding and packing in c?
What is the heap?
Is c is a middle level language?
Is struct oop?
Difference between goto, long jmp() and setjmp()?
What is scanf_s in c?
Explain how can you avoid including a header more than once?
What is extern variable in c with example?
What is the return type of sizeof?
Linked list is a Linear or non linear explain if linear how it working as a non linear data structures
Explain the difference between structs and unions in c?
Explain what standard functions are available to manipulate strings?
What is scope and lifetime of a variable in c?
What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.