0% found this document useful (0 votes)
18 views

Manual # 9

This manual discusses sorting techniques using arrays. It provides an introduction to selection sort and bubble sort algorithms. The document specifically contains source code for implementing selection sort in C++. It accepts array size as input, sorts the array in ascending order using selection sort technique, and prints the original and sorted arrays. The author is Engr. Ali Faisal Murtaza and it is part of the Introduction to Computing subject area.

Uploaded by

musa
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Manual # 9

This manual discusses sorting techniques using arrays. It provides an introduction to selection sort and bubble sort algorithms. The document specifically contains source code for implementing selection sort in C++. It accepts array size as input, sorts the array in ascending order using selection sort technique, and prints the original and sorted arrays. The author is Engr. Ali Faisal Murtaza and it is part of the Introduction to Computing subject area.

Uploaded by

musa
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Manual # 9

Topic:
Sorting Techniques Using Arrays

Subject:
Introduction to Computing

Author:
Engr. Ali Faisal Murtaza

1
---------------------------------------------------------------------------------
Selection Sort using Arrays
#include<iostream.h>
int main()
{
int a[100],i,j,size,temp;
cout<<"Enter the size of array: ";
cin>>size;

for(i=0;i<size;i++)
{
cin>>a[i];

cout<<"Original: "<<endl;
for(i=0;i<size;i++)
{
cout<<a[i]<<" --> ";
}

for(i=0;i<(size-1);i++)
{
for(j=i+1;j<size;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}

cout<<"\n";

cout<<"Sorted: "<<endl;
for(i=0;i<size;i++)
{
cout<<a[i]<<" --> ";
}
cout<<"\n";

2
return 0;
}
------------------------------------------------------------------------------------------------------------
Q1: Bubble Sort using Arrays
---------------------------------------------------------------------------------

You might also like