//Inserting an element at any position in Array
#include<stdio.h>
#include<conio.h>
#define SIZE 10
int ch,array[SIZE];
void main()
{
clrscr();
while(1)
{
int top,i,ch1,num,data;
printf("*** Menu ***\n 1. At Begining\n 2. In Between\n 3. At End\n");
printf("Enter your choice ");
scanf("%d",&ch);
if(top==SIZE-1)
printf("Array is full!");
else
{
switch(ch)
{
case 1:
printf("Enter the number to be inserted into the begining of array");
scanf("%d",&data);
top++;
array[top]=data;
break;
case 2:
printf("Where do you want to insert an element (0-10)");
scanf("%d",&num);
while(num<0||num>SIZE);
printf("Enter data to insert");
scanf("%d",&data);
top++;
for(i=top;i>num-1;i--)
arra[i+1]=stack[i];
array[num]=data;
break;
case 3:
printf("Enter the element at the end of stack ");
scanf("%d",&num);
array[SIZE]=num;
break;
}
}
return 0;
}
int pop()
{
if(top==-1)
printf("Array is empty\n");
else
{
item=array[top];
top--;
printf("The deleted item from stack is %d\n",item);
}
return 0;
}
int display()
{
int i;
if(top==-1)
printf("Stack underflow!");
else
{
printf("Stack displays\n");
for(i=top;i>=0;i--)
{
printf("%3d\n",array[i]);
}
}
return 0;
}