Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion DataStructures/Arrays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ int main()
for (int i=0; i<10; i++){
cout<<arr[i]<<" ";
}


//Insertion of element
int k, j, n=10;
cout<<"Enter the position where you want to insert the element:\n";
cin>>k;
cout<<"Enter the element you want to insert:\n";
cin>>item;
for(j=n;j>=k;j--)
{
arr[j+1]=arr[j];
}
arr[k]=item;
n=n+1;
cout<<"The new array after the insertion of element is:";
for(i=1;i<=n;i++)
{
cout<<arr[i]<<" ";
}
return 0;
}