program in c to insert a number in given position in an array
#include<stdio.h> #include<conio.h> void main() { int i,a[15],l,c=0,j,n1,n,p; printf("Enter number of elements you want to insert:-"); scanf("%d",&n); printf("Enter %d numbers:-",n); for(i=0;i<n;i++) scanf("%d",&a[i]); printf("Enter number And Position :-"); scanf("%d%d",&n1,&p); for(i=n-1;i>=p-1;i--){ a[i+1]=a[i];} a[p-1]=n1; for(i=0;i<=n;i++) printf("%3d",a[i]); getch(); }
Output:-
Insert array element |
Related Programs:-
0 Comments