#include<conio.h> void main() { clrscr(); int arr[50], size, insert, i, pos; printf("Enter Array Size : "); scanf("%d",&size); printf("Enter array elements : "); for(i=0; i<size; i++) { scanf("%d",&arr[i]); } printf("Enter element you want to Insert : "); scanf("%d",&insert); printf("Enter Position : "); scanf("%d",&pos); for(i=size; i>pos; i--) { arr[i]=arr[i-1]; } arr[pos]=insert; printf("Element Added\n"); printf("Updated Array : \n"); for(i=0; i<size+1; i++) { printf("%d ",arr[i]); } getch(); }
C program to insert element in array at the particular position.
Reviewed by
on
December 25, 2019
Rating:
No comments: