Selection sort method in Single dimensional array

Selection 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.

Selection sorting on a single dimensional array using functions. IN this sorting method first of all we try to find out lowest number available in the list and then swap that position’s value with the value available in that step position.

/* selection sort algorithm
made by :rakesh kumar
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 selection_sort(int x[] ,int n)
int i,j,low,pos,temp;
low = x[i];
pos = i;
low = x[j];
pos= j;
temp = x[i];
x[i]= x[pos];
x[pos]= temp;


int main()
int x[10];
cout<<“\n sorted Array :”;
return 0;

Other most useful sorting algorithm are

  1. Bubble sort method program using single dimensional array
  2. Insertion sort method program using single dimensional array

If you need any other program on any sorting method, do post your request in comments.

Print Friendly, PDF & Email

Related Posts

If you like CBSEToaday and would like to contribute, you can also write an article using submit article or mail your article to See your article appearing on the main page and help other students/teachers.