Thursday, 18 July 2013

Program in C to Insert an Element at the Specified Position in Array

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,n,k,item,pos;
clrscr();
printf(“Enter the element of array=\n”);
scanf(“%d”,&n);
printf(“Enter the element of array=\n”);
for(i=1;i<=n;i++)
{
scanf(%d”,&a[i]);
}
printf(“Enter the position”);
scanf(“%d”,&k);
for(i=n;i>=pos;i--)
{
a[i+1]=a[i];
}
printf(“Enter the value you want to insert\n”);
scanf(“%d”,&item);
for(i=1;i<=n;i++)
{
printf(“Element is %d”,a[i]);
}
getch();

}

No comments:

Post a Comment