ExplanationHere, sorting of numbers is made through the exchange method. The element number
given by the outer for loop of an array num [ 10 ] is compared with all the other elements of the same
array If the first element is larger than the successive element, the larger value is assigned to variable
'temp7 (temp=num[i] ;) andinplaceof larger value smaller value is replaced (num [i]=num[j];).
In place of smaller value the value of ' temp •variable (which is larger) is replaced (num [ j ] = temp;).
Thus, the array elements in ascending order are obtained using the above program.
7.22 Write ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.