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
What is the total generic pointer type?
Which is better between malloc and calloc?
main() { printf("hello"); fork(); }
What is LINKED LIST? How can you access the last element in a linked list?
Write a c program to build a heap method using Pointer to function and pointer to structure ?
what are the 10 different models of writing an addition program in C language?
How to define structures? ·
what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
An arrangement of information in memory in such a way that it can be easily accessed and processed by a programming language a) string b) data structure c) pointers d) array
Is int a keyword in c?
What are the types of variables in c?
What is the benefit of using #define to declare a constant?
Are there constructors in c?
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
What is c programming structure?