#include"stdio.h"
int main()
{
int a[10];
int top;
int i,j, n;
printf("\n\t\t Stack Implementation using ARRAY");
top=9;
do
{
printf("\n 1. Push 2. POP 3. View Stack 4. Exit. Enter your Choice : ");
scanf("%d",&i);
switch(i)
{
case 1:
if(top>0)
{
printf("\n Enter a value to push into stack : ");
scanf("%d",&n);
a[top]=n;
top--;
}
else
printf("\nStack Full\n");
break;
case 2:
if (top<9)
{
printf("\n%d is the poped element from stack",a[top+1]);
top=top + 1;
}
break;
case 3:
printf("\nThe elements available in stack are \n Top:");
for(j=top+1;j<=9;j++)
printf(" --> %d",a[j]);
break;
}
}while(i != 4);
printf("End of Stack Implementation");
}
This comment has been removed by a blog administrator.
ReplyDelete