Bubble Sort - Implementation in C++

It is a comparison-based sorting algorithm used to sort a given array in ascending or descending order.  In this, we repeatedly compare the pairs of adjacent elements and then swap them if they exist in the wrong order.

Let us take an example to understand this, A[5] = { 5, 6, 1, 2, 3 }

Below is the Implementation of this algorithm in C++.