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

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

683


simple program of graphics and their output display

1471


What do you mean by invalid pointer arithmetic?

638


What is methods in c?

649


Explain what is the advantage of a random access file?

670






what is the basis for selection of arrays or pointers as data structure in a program

3791


What are the properties of union in c?

596


Can we declare variable anywhere in c?

540


How can I read a binary data file properly?

637


What are the advantages of using macro in c language?

596


Which is the memory area not included in C program? give the reason

1510


in iso what are the common technological language?

1639


Can we declare variables anywhere in c?

583


What is the 'named constructor idiom'?

645


program to convert a integer to string in c language'

1989