Bubble sort in Single dimensional array

Bubble sort method is one of the must know the sorting algorithm for each and every computer science student.

In this sorting program, we are sorting an integer array of size 10 using bubble sort method.  This method is sorting this array into ascending order.

Bubble sorting on a single dimensional array using functions.

/* Bubble sort program using function and array
#include “io.cpp”
using namespace std;

void output(int a[],int n){
for(int i=0;i<n;i++)

void input(int x[],int n){
for(int i=0;i<n;i++)
cout<<“Enter x[“<<i+1<<“] number : “;

void bubble(int a[],int n){
int i,j,temp;
for(i=0;i<n-1;i++) // steps
temp = a[j];
a[j]= a[j+1];

int main(){
int a[10];
//input phase
//processing phase
// output phase
cout<<“n Sorted array :”;
return 0;

Other useful sorting algorithm are

Selection sort method program using single dimensional array

Insertion sort method program using single dimensional array

Author: rakesh kumar

cbsetoday.com is my online home, here I share all the information related to education, programming - and everything else that attract me. You can get in touch with me in these social sharing websites
Download File :

Leave a Reply