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


Please Help Members By Posting Answers For Below Questions

What is && in c programming?

938


How are Structure passing and returning implemented by the complier?

962


When a c file is executed there are many files that are automatically opened what are they files?

854


What is the difference between fread buffer() and fwrite buffer()?

941


I heard that you have to include stdio.h before calling printf. Why?

847


please explain every phase in the "SDLC" in the dotnet.

2419


application areas a 'c' a) operating system b) graphics, interpreter, assembler c) program evalution, communication softwares d) all the above

868


What are the Advantages of using macro

931


What are the 4 types of unions?

837


What is a example of a variable?

798


What's a good way to check for "close enough" floating-point equality?

877


What is the time and space complexities of merge sort and when is it preferred over quick sort?

900


What are multidimensional arrays?

901


What is masking?

929


Is register a keyword in c?

863