In this article you will get program for bubble sort in C++.
Bubble sort is a sorting technique in which each pair of adjacent elements are compared, if they are in wrong order we swap them. This algorithm is named as bubble sort because, same as like bubbles the smaller or lighter elements comes up (at start) and bigger or heavier elements goes down (at end). Below I have shared a program for bubble sort in C++ which sorts a list of numbers in ascending order.
Also Read: Program for Quick Sort in C++
Program for Bubble Sort in C++
using namespace std;
cout<<"Enter the size of array: ";
cout<<"Enter the array elements: ";
cout<<"Array after bubble sort:";