Skip to content

Instantly share code, notes, and snippets.

@rahulmalhotra
Created November 26, 2017 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulmalhotra/feb4370854951e70e38e770bbd2694d3 to your computer and use it in GitHub Desktop.
Save rahulmalhotra/feb4370854951e70e38e770bbd2694d3 to your computer and use it in GitHub Desktop.
Insertion Sort code compatible with Codeblocks IDE
#include<iostream>
using namespace std;
int main()
{
int size,arr[50],j=0,store;
cout<<"\n\nEnter the size of the Array";
cin>>size;
cout<<"\n\nEnter the array";
for(int i=1;i<=size;i++)
{
cin>>arr[i];
}
for(i=1;i<=size;i++)
{
store=arr[i];
j=i-1;
while(store<arr[j])
{
arr[j+1]=arr[j];
j--;
}
arr[j+1]=store;
}
for(i=1;i<=size;i++)
cout<<arr[i];
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment