Skip to content

Commit 4271237

Browse files
committed
code changed to input driven
1 parent 128d3a4 commit 4271237

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

insertion_sort/insertion_sort.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ void display(int array[], int size)
2424
}
2525
int main()
2626
{
27-
int array[] = {5, 4, 233, 32, 1, 4, 34, 3, 23};
28-
int size = sizeof(array) / sizeof(array[0]);
27+
int size;
28+
cout<<"Enter the size of the array :"<<endl;
29+
cin>>size; //size of the array
30+
int array[size];
31+
cout<<"Enter array elements"<<endl;
32+
for(int i=0;i<size;i++)
33+
cin>>array[i]; //taking input
2934
cout << "unsorted array is :" << endl;
3035
display(array, size); //display unsorted array
3136
insertionSort(array, size);

0 commit comments

Comments
 (0)