CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
int i,val,pos,n,a[10];
clrscr();
printf("Enter n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter a[%d]",i);
scanf("%d",&a[i]);
}
printf("Enter the possition for insertation ");
scanf("%d",&pos);
printf("Enter the value ");
scanf("%d",&val);
for(i=n-1;i>=pos-1;i--)
{
a[i+1]=a[i];
}
a[pos-1]=val;
printf("The resultant array is");
for(i=0;i<=n;i++)
{
printf("\n%d",a[i]);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,val,pos,n,a[10];
clrscr();
printf("Enter n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter a[%d]",i);
scanf("%d",&a[i]);
}
printf("Enter the possition for insertation ");
scanf("%d",&pos);
printf("Enter the value ");
scanf("%d",&val);
for(i=n-1;i>=pos-1;i--)
{
a[i+1]=a[i];
}
a[pos-1]=val;
printf("The resultant array is");
for(i=0;i<=n;i++)
{
printf("\n%d",a[i]);
}
getch();
}
No comments:
Post a Comment