Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int arr[50], size, insert, i, pos;
- cout<<"Enter Array Size : ";
- cin>>size;
- cout<<"Enter array elements : ";
- for(i=0; i<size; i++)
- {
- cin>>arr[i];
- }
- cin>>insert;
- cin>>pos;
- for(i=size; i>pos; i--)
- {
- arr[i]=arr[i-1];
- }
- arr[pos]=insert;
- cout<<"Element inserted successfully..!!\n";
- cout<<"Now the new array is : \n";
- for(i=0; i<size+1; i++)
- {
- cout<<arr[i]<<" ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement