write a program to arrange the contents of a 1D array in
ascending order
Answer Posted / prakashmca
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],n,i,j,temp;
clrscr();
printf("\n enter the size of the array");
scanf("%d",&n);
printf("\n enter the contents of the array");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n-1;i++)
{
for(j=0;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
getch();
}
| Is This Answer Correct ? | 7 Yes | 14 No |
Post New Answer View All Answers
What is the significance of scope resolution operator?
Why is struct padding needed?
How can you allocate arrays or structures bigger than 64K?
How will you delete a node in DLL?
What is the general form of a C program?
What are multidimensional arrays?
What are nested functions in c?
In C programming, how do you insert quote characters (‘ and “) into the output screen?
What is bin sh c?
I need testPalindrome and removeSpace
#include
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
What are header files in c?
Explain what happens if you free a pointer twice?
What is a double c?
What is data types?