#include<stdio.h>
void main()
{
int s[50],top=0,ch,size,temp,i;
printf("Enter the Size of stack");
scanf("%d",&size);
do
{
printf("\n 1.PUSH\n 2.POP\n 3.Display\n4.Exit");
printf("\n Enter your choice");
scanf("%d",&ch);
switch(ch)
{
case 1:
if(top<=size)
{
++top;
printf("\nEnter the stack value");
scanf("%d",&s[top]);
}
else
printf("\nStack is full");
break;
case 2:
if(top==0)
printf("\n Stack is empty");
else
{
temp=s[top];
printf("\nDeleted Item=%d",temp);
--top;
}
break;
case 3:
printf("\nStack order: ");
for(i=1;i<=top;i++)
printf("\t%d",s[i]);
case 4:
exit(0);
default:
printf("\nWrong Choice.... Try again...!!");
}
}while(ch!=4);
}
void main()
{
int s[50],top=0,ch,size,temp,i;
printf("Enter the Size of stack");
scanf("%d",&size);
do
{
printf("\n 1.PUSH\n 2.POP\n 3.Display\n4.Exit");
printf("\n Enter your choice");
scanf("%d",&ch);
switch(ch)
{
case 1:
if(top<=size)
{
++top;
printf("\nEnter the stack value");
scanf("%d",&s[top]);
}
else
printf("\nStack is full");
break;
case 2:
if(top==0)
printf("\n Stack is empty");
else
{
temp=s[top];
printf("\nDeleted Item=%d",temp);
--top;
}
break;
case 3:
printf("\nStack order: ");
for(i=1;i<=top;i++)
printf("\t%d",s[i]);
case 4:
exit(0);
default:
printf("\nWrong Choice.... Try again...!!");
}
}while(ch!=4);
}
No comments:
Post a Comment
Thank you for using this blog.