write a program to arrange the contents of a 1D array in
ascending order

Answer Posted / poornima

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]);
}
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("\nAscending Order\n");
for(i=0;i<n;i++)
{
printf("%d\n",a[i]);
}
return 0;
}

Is This Answer Correct ?    65 Yes 22 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a rvalue?

977


How can you restore a redirected standard stream?

822


What does c in a circle mean?

796


How can I write a function that takes a format string and a variable number of arguments?

858


What are the advantages of c language?

865


difference between native and cross compilers

1895


How can I change their mode to binary?

915


what is recursion in C

857


Why is c called c not d or e?

870


GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA

1696


Is c call by value?

828


What are the advantage of c language?

799


Explain why C language is procedural?

997


Is c is a procedural language?

845


Is null always defined as 0(zero)?

848