#include "conio.h"
#include "stdio.h"
void main()
{
int a[12],i,s,c,n;
clrscr();
printf("Welcome to Insertion in stack of n elements\n");
printf("Enter the values of 'n'= ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\n Enter a number");
scanf("%d",&a[i]);
}
printf("\nThe initial array is\n");
for(i=1;i<=n;i++)
{
printf("%d ",a[i]);
}
printf("\n\nEnter the location where u want to insert : ");
scanf("%d",&s);
printf("\nEnter the number to be inserted : ");
scanf("%d",&c);
for(i=n;i>=s;i--)
{
a[i+1]=a[i];
}
a[s]=c;
printf("\n The array after insertion is\n\n");
for(i=1;i<=(n+1);i++)
{
printf("%d ",a[i]);
}
getch();
}
0 comments:
Post a Comment