0% found this document useful (0 votes)
2 views1 page

Newwe

Uploaded by

siddeshmachale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Newwe

Uploaded by

siddeshmachale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Prac cal 16 2223 case 2:pop();break;

#include<stdio.h> case 3:display();break;


#include <stdlib.h> case 4:exit(0);
#define max 20 default:prin ("You Enter Wrong
int stack[max],ch,top=-1,item,i; Number...");
void push(){ }
int item; }
if(top==max-1){ return 0;
prin ("stack is full"); }
}else{ OUtPUT:-
prin ("Enter element to push:"); STACK IMPLEMENTATION
scanf("%d",&item); USING ARRAY
top=top+1; 1:push
stack[top]=item; 2:pop
}} 3:Display
void pop(){ 4:exit
if(top==-1){ Enter your choice
prin ("stack is empty"); 1
}else{ Enter element to push:20
prin ("poped element is: 1:push
%d",stack[top]); 2:pop
top--; 3:Display
}} 4:exit
void display(){ Enter your choice
if(top==-1){ 1
prin ("stack is empty"); Enter element to push:10
}else{ 1:push
prin ("stack elements are:\n"); 2:pop
for(i=top;i>=0;i--){ 3:Display
prin ("%d\n",stack[i]); 4:exit
}}} Enter your choice
int main(){ 2
prin ("\t\tSTACK IMPLEMENTATION USING poped element is: 10
ARRAY"); 1:push
int ch; 2:pop
while(1){ 3:Display
prin ("\n1:push\n2:pop\n3:Display\n4:exi 4:exit
t\n");
prin ("\nEnter your choice\n"); Enter your choice
scanf("%d",&ch); 3
switch(ch){ stack elements are:
case 1:push();break; 20

You might also like