Program
#include<stdio.h>
int s[20],max=5,top=0;
main()
{
int push();
int pop();
int printing();
int ch;
while(1)
{
printf("Type 1 go for Push Operation");
printf("\nType 2 go for Pop Operation");
printf("\nType 3 go for Printing");
printf("\nType 4 exit");
printf("Enter Choice");
scanf("%d",&ch);
switch(ch)
{
case 1:
{
push();
break;
}
}
case 2:
{ac
pop();
break;
}
case 3:
{
printing();
break;
}
}
case 4:
{
exit();
break;
}
}
}
}
}
}
}
int push()
{
int x;
if(top>max)
{
printf("Stack is Overflow");
exit();
}
}
else
{
printf("Enter Data");
scanf("%d",&x);
top=top+1;
s[top]=x;
}
}
}
}
int pop()
{
if(top==0)
{
printf("Stack is Underflow");
exit();
}
}
else
top=top-1;
}
}
int printing()
{
int i;
for(i=1;i<=top;i++)
printf("%d",s[i]);
}
}
No comments:
Post a Comment