PGM 3
PGM 3
PGM 3
#include<stdio.h>
#include<stdlib.h>
#define MAX 4
int stack[MAX],item,ch,top=-1,count=0,status=0;
if(top==(MAX-1))
else
stack[++top]=item;
status++;
int elem;
if(top==-1)
else
elem=stack[top--];
status--;
return elem;
}
int i,temp;
temp=status;
for(i=0;i<temp;i++)
if(stack[i]==pop(stack))
count++;
if(temp==count)
else
int i;
if(top==-1)
else
for(i=top;i>=0;i--)
printf("\n%d",stack[i]);
printf("\n");
}
void main()
do{
printf("\n--MAINMENU--\n");
scanf("%d",&ch);
switch(ch)
scanf("%d",&item);
push(stack,item);
break;
case 2: item=pop(stack);
break;
case 3: palindrome(stack);
break;
case 4: display(stack);
break;
default: exit(0);
break;
}while(1);
OUTPUT:
--MAINMENU--
--MAINMENU--
--MAINMENU--
--MAINMENU--
--MAINMENU--
Poppoed element =1
Poppoed element =2
Poppoed element =1
stack contents are palindrome
--MAINMENU--