PROGRAM TO PERFORM PUSH OPERATION ON STACK USING ARRAY

/*PROGRAM TO PERFORM PUSH OPERATION ON STACK USING ARRAY*/
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#define MAX 5
void main()
{
int top=0,n,a[MAX],i;
char ch;
clrscr();
//PUSH OPERATION
printf(“Pushing elements into the stack: \n”);
do
{
if(top>=MAX)
{
printf(“\nArray is overflow\n”);
break;
}
else
{
printf(“enter item:”);
scanf(“%d”,&n);
a[top]=n;
top++;
printf(“do u want to insert more elements”);
fflush(stdin);
scanf(“%c”,&ch);
}
}
while(ch==’y');
printf(“after push the array is:”);
for(i=0;i<top;i++)
{
printf(“\n%d”,a[i]);
}
getch();
}