adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Program in C to insert a number in given position in an array

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 element in array


Insert array element



Related Programs:-

Post a Comment

0 Comments