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
What is && in c programming?
How are Structure passing and returning implemented by the complier?
When a c file is executed there are many files that are automatically opened what are they files?
What is the difference between fread buffer() and fwrite buffer()?
I heard that you have to include stdio.h before calling printf. Why?
please explain every phase in the "SDLC" in the dotnet.
application areas a 'c' a) operating system b) graphics, interpreter, assembler c) program evalution, communication softwares d) all the above
What are the Advantages of using macro
What are the 4 types of unions?
What is a example of a variable?
What's a good way to check for "close enough" floating-point equality?
What is the time and space complexities of merge sort and when is it preferred over quick sort?
What are multidimensional arrays?
What is masking?
Is register a keyword in c?