answersLogoWhite

0

#include<stdio.h>

#include<conio.h>

void main()

{

int a[10],i,n,j,t;

clrscr();

printf("enter size of array: ");

scanf("%d",&n);

printf(" enter array elements: ");

for(i=0;i<n;i++)

{

scanf("%d",&a[i]);

}

printf(" array before sorting\n");

for(i=0;i<n;i++)

{

printf("%d\n",a[i]);

}

for(i=0;i<n;i++)

{

for(j=i+1;j<n;j++)

{

if(a[i]>a[j])

{

t=a[i];

a[i]=a[j];

a[j]=t;

}

}

}

printf("\n after sorting\n");

for(i=0;i<n;i++)

{

printf("%d\n",a[i]);

}

getch();

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Sort array in ascending descending order in python?

Using sorted(array,reverse=True)


Which action do you perform on a data source to reorganize the order of the record for a merge?

You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.


How do you sort variable in ascending or descending order both in php?

Assuming that the values are stored in an array, you can use the php function sort($array) to sort ascending, and rsort to sort descending. The following link gives a table that lists all of the built in PHP sort functions: http://php.net/manual/en/array.sorting.php


What two ways can you sort information?

In ascending order and in descending order.


You can sort numeric fields in ascending order only?

No. They can be sorted either ways. Ascending or Descending.


What is the most efficient way to find the median of an unsorted array of numbers?

One efficient way to find the median of an unsorted array of numbers is to first sort the array in either ascending or descending order, then determine the middle value as the median.


Data organized in ascending or descending order?

ranking correct answer is numerical order


How can you tell what sort has been preformed out of Ascending and Descending on a computer?

For alphabetical, Ascending is Z-&gt;A and Descending is A-&gt;Z


How you rearrange the data in ascending or descending order?

Select the data you want to sort. Then use the Sort option, picking A to Z for ascending order or Z to A for descending order. You can choose which columns to sort by and even to do primary and secondary sorts, like sorting first by surname and then by first name.


What button do you use to put data in a specific order?

The sort buttons. You can use them to sort in ascending order or descending order. One has A above Z with a down arrow enabling you to sort in ascending order. The other has Z above A with a down arrow enabling you to sort in descending order. Once your data is selected, you can click the appropriate button to do the sort you want.


How do you display 15 numbers in an ascending order using an array?

Sort the array then traverse the array, printing the element values as you go.


Sort the array of integers in Descending order?

Make use of Java's robust library: // filled with various ints int[] a; // temporary variable for swapping values int temp; // sort with fast, built-in algorithm java.util.Arrays.sort(a); // reverse the array for( int i = 0; i &lt; a.length/2; ++i ) { temp = a[i]; a[i] = a[a.length - i - 1]; a[a.length - i - 1] = temp; } Obviously, if you're concerned with execution speed you could write your own sort method which would sort into descending order instead of ascending order (perhaps by modifying Java's sort algorithm).