write a program to arrange the contents of a 1D array in
ascending order
Answer Posted / kameshav
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]);
}
printf("\nAscending Order\n");
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("%d\n",a[i]);
}
return 0;
}
| Is This Answer Correct ? | 23 Yes | 19 No |
Post New Answer View All Answers
int i=10; printf("%d %d %d", i, i=20, i);
Write a code to generate a series where the next element is the sum of last k terms.
What is the use of bitwise operator?
Explain how does flowchart help in writing a program?
What is substring in c?
What is the difference between local variable and global variable in c?
In C programming, how do you insert quote characters (‘ and “) into the output screen?
How do you print only part of a string?
What is the explanation for the dangling pointer in c?
Which header file should you include if you are to develop a function which can accept variable number of arguments?
Explain how do you override a defined macro?
What are different storage class specifiers in c?
What is the meaning of ?
What are the types of macro formats?
explain what is an endless loop?