STACK
STACK
Design, Develop and Implement a menu driven Program in C for the following operations on
STACK of Integers (Array Implementation of Stack with maximum size MAX)
e. Exit
#include<stdio.h>
#include<stdlib.h>
#define MAX 20
void main()
for(;;)
printf("\nMenu\n");
scanf("%d", &ch);
switch(ch)
case 1:
if(stack_full(top))
printf("Stack Full\n");
else
printf("Enter an Element\n");
scanf("%d", &ele);
break;
case 2:
if(stack_empty(top))
printf("Stack Empty\n");
else
break;
case 3:
if(stack_empty(top))
printf("Stack Empty\n");
printf("Stack is Palindrome\n");
display(stack, top);
}
else
break;
case 4:
if(stack_empty(top))
printf("Stack Empty\n");
else if(stack_full(top))
printf("Stack Full\n");
else
break;
case 5:
if(stack_empty(top))
printf("Stack Empty\n");
else
display(stack, top);
break;
case 6:
exit(0);
if(top == MAX-1)
return 1;
return 0;
}
int stack_empty(int top)
if(top == -1)
return 1;
return 0;
stack[++(*top)] = ele;
return stack[(*top)--];
int i, not_palindrome=0;
if(stack[i] != stack[top-i])
not_palindrome = 1;
break;
}
if(not_palindrome)
return 0;
else
return 1;
int i;
printf("\n");