Professional Documents
Culture Documents
Seta 1
Seta 1
#include <stdio.h>
#include <stdlib.h>
#include "Sstack.h"
#define MAX 20
void main()
{
struct stack s1;
int ch, x;
init(&s1);
do
{
printf("\n 1 - Push");
printf("\n 2 - Pop");
printf("\n 3 - Empty");
printf("\n Enter choice : ");
scanf("%d", &ch);
switch (ch)
{
case 1:
printf("Enter data : ");
scanf("%d", &x);
push(&s1,x);
printf("stack elements are");
display(&s1);
break;
case 2:
if(isEmpty(&s1))
printf("stack is empty");
else
printf("poped element is %d \n",pop(&s1));
printf("stack elements are");
display(&s1);
break;
case 3:
if(isEmpty(&s1))
printf("stack is empty");
else
printf("stack is not empty");
break;
}
}
while(ch>0 && ch<3);
}
#define MAX 20
struct stack
{
int data[MAX];
int top;
};