c program to insert any element in array

c program to insert any element in array

if you want to insert any element in array at any position then go through the given programming solution below.

#include<stdio.h>
#include<string.h>
int main(){
int a[20],i,n,p,v;
printf("enter size of array\n");
scanf("%d",&n);
printf("enter the element of array\n");
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
printf("enter the position at which you want to enter  the element and value of element\n");
scanf("%d%d",&p,&v);
p=p-1;
printf("your final array is\n");
for(i=0;i<n;i++){
if(i==p){
a[p]=v;
}
printf("%d\n",a[i]);
}
}
c program to insert any element in array

Comments

Post a Comment

Popular posts from this blog

c program to convert any three digit number in words

c program to remove characters in string except alphabets