Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int i,n,num,pos,ar[10];
- printf("Enter the number of elements in the array: ");
- scanf("%d",&n);
- for(i=0;i<n;i++)
- {
- printf("\nEnter the values: ");
- scanf("%d",&ar[i]);
- }
- printf("\nEnter the number to be inserted: ");
- scanf("%d",&num);
- printf("Enter the position to be inserted: ");
- scanf("%d",&pos);
- for(i=n;i>=pos;i--)
- ar[i+1]=ar[i];
- ar[pos]=num;
- n++;
- printf("The array after insertion: ");
- for(i=0;i<n;i++)
- printf("\n%d",ar[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement