Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Insert element position
1. Write a program to insert an element
into an array at a given position.
2. Agenda
1. Program in c++
2. Array declaration and definition
3. Insert new element at the specified position
4. Print the array
1. Before Insertion
2. After Insertion
3. Logic
• Given array for example:
• arr[]={1,2,3,4,5}
• Specify position at which position the num. to be
present ex:2
• Enter what element to be inserted:6
• Loop:
• for(i=n; i>pos-1;i--)
• { arr[i]=arr[i-1]}
• arr[pos-1]=ele
• Print Array before insertion and after insertion