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
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
simple program of graphics and their output display
What do you mean by invalid pointer arithmetic?
What is methods in c?
Explain what is the advantage of a random access file?
what is the basis for selection of arrays or pointers as data structure in a program
What are the properties of union in c?
Can we declare variable anywhere in c?
How can I read a binary data file properly?
What are the advantages of using macro in c language?
Which is the memory area not included in C program? give the reason
in iso what are the common technological language?
Can we declare variables anywhere in c?
What is the 'named constructor idiom'?
program to convert a integer to string in c language'