🔥 Burn Fat Fast. Discover How! 💪

include #incluse #define size 5 int array[size]; int top=-1; v | OFF CAMPUS UPDATES

include
#incluse
#define size 5
int array[size];
int top=-1;
void push()
{
int num;
if(top == size-2){
printf("Overflow\n");
}
else{
printf("Enter the elements");
scanf("%d\n",&num);
top+=1;
array[top]=num;
}
}
void pop()
{
if(top==-1)
printf("underflow");
else
{
printf("the popped element is %d",array[top]);
top-=1;
}
}
void display()
{
if(top==-1)
{
printf("Stack is empty");
}
else{
printf("the elements are");
for(int i=top;i>0;i--){
printf("%d",array[i]);
}
}
}
int main()
{
int choice;
while(1)
{
printf("\nOperations performed by Stack");
printf("\n1.Push the element\n2.Pop the element\n3.Display\n4.End");
printf("\n\nEnter the choice:");
scanf("%d",&choice);

switch(choice)
{
case 1: push();
break;
case 2: pop();
break;
case 3: display();
break;
case 4: exit(0);

default: printf("\nInvalid choice!!");
}
}
}

Stack Operation