Fori1 and j 3, if condition is satisfi ed and a[1] and a[3] are swapped array which becomes as
follows:
Indexa[0]a[1]a[2]a[3]a[4]
Initially01432
So, after the end of inner for loop the array will be as follows:
Indexa[0]a[1]a[2]a[3]a[4]
Initially01432
This means that the second smallest number is at the second place in the array. So, when the outer loop
fi nishes, the array will be stored in ascending order.
5.6 TWO-DIMENSIONAL (2-D) ARRAY
A two-dimensional array can be thought of as a matrix with rows and columns. A multi-dimensional array
is like an array ...
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.