answersLogoWhite

0


Best Answer

void main()

{

int i,j,temp1,temp2;

int arr[8]={5,3,0,2,12,1,33,2};

int *ptr;

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

{ for(j=0;j<7-i;j++) {

if(*(arr+j)>*(arr+j+1))

{ ptr=arr+j;

temp1=*ptr++;

temp2=*ptr;

*ptr--=temp1;

*ptr=temp2;

clrscr();

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

printf(" %d",arr[i]);

getch(); }

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Wap to sorting the element of the array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the Application of quick sort?

Sorting an array.


C program to sort all elements of a 4x4 matrix?

This type of sorting can b performd by simply transferring all the matrix elements in a single dimension array of 1X16 size and then sorting this array and then transferring the elements back to 4X4 matrix. You can also treat the 4x4 matrix as a simple array using pointers and, thus, not need to transfer from matrix to array and back. Example, using ellipses (...) to simulate indentation for clarity... int matrix[4][4] = {...some values...} int *element; int flag = 1; while (flag == 1) { /* simple bubble sort */ ... flag = 0; ... /* loop from first element to next to last element */ ... for (element = &amp;matrix[0][0]; element &lt; &amp;matrix[3][3]; element ++) { ... ... if (*element &gt; *(element + 1)) { ... ... ... flag = 1; ... ... ... *element ^= *(element + 1); /* exclusive or swap */ ... ... ... *(element + 1) ^= *element; ... ... ... *element ^= *(element + 1); ... ... } ... } }


Sorting of array through function in java programming?

// the build in sorting functions in Java will sort pretty much any array // of Comparable objects or primitives Arrays.sort(someArray);


What is useful to implement quick sort?

Knowledge and experience.


Sorting an array of numbers in java?

here you will a good example on java sorting algorithm application http://javacodespot.blogspot.com/2010/08/java-sorting-animations.html http://javacodespot.blogspot.com/


What is internal and external sorting techniques?

Internal sorting it means we are arranging the number within the array only which is in computer primary memory. External sorting it is the sorting of numbers from the external file by reading it from secondary memory.


Will an array element be deleted when you retrieve it from the array?

You cannot delete from an array.


How do you find particular element in array?

by using index position we can find the particular element in array.


Which element of array does this expression refer num5?

which element of the array does this expression reference num[5]


Sorting an array of objects through in built function?

Object[] arrayToBeSorted; Arrays.sort(arrayToBeSorted);


Who introduce selection sorting algorithm?

in selection sorting at first we take first element of the list and start comparing with all the successive element of that list


What is the index number of the last element of an array with 9 elements?

(array.length - 1) will find the index of the last element in an array (or -1 if the array is empty).