Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int stack[5],n,element,top=-1;
- x:
- printf("enter a number within 1 to 4\n");
- scanf("%d",&n);
- while(n!=4)
- {
- if(n==1)
- {
- top++;
- printf("enter ur element\n");
- scanf("%d",&element);
- stack[top]=element;
- if(top>=5)
- {
- printf("NO SPACE TO PUSH");
- }
- goto x;
- }
- else if(n==2)
- {
- printf("%d\n",stack[top]);
- top--;
- if(top<0)
- {
- printf("nothing to pop\n");
- }
- goto x;
- }
- else if(n==3)
- {
- printf("%d\n",stack[top]);
- if(top<0)
- {
- printf("nothing on top\n");
- }
- goto x;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement