Advertisement
eee

Untitled

eee
Jul 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5. int i,n,num,pos,ar[10];
  6. printf("Enter the number of elements in the array: ");
  7. scanf("%d",&n);
  8. for(i=0;i<n;i++)
  9. {
  10. printf("\nEnter the values: ");
  11. scanf("%d",&ar[i]);
  12. }
  13. printf("\nEnter the number to be inserted: ");
  14. scanf("%d",&num);
  15. printf("Enter the position to be inserted: ");
  16. scanf("%d",&pos);
  17. for(i=n;i>=pos;i--)
  18. ar[i+1]=ar[i];
  19. ar[pos]=num;
  20. n++;
  21. printf("The array after insertion: ");
  22. for(i=0;i<n;i++)
  23. printf("\n%d",ar[i]);
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement