Session 9 4 alp to display the current system time using dos int 21 h
Bcsl 033 data and file structures lab s4-3
1. S4-3
Write a program in ‘C’ language to implement multiple stacks in a
single array.
#include<stdio.h>
#include<conio.h>
int sno,t1,t2;
int a[20];
void push(int,int);
void pop(int);
void disp();
void main()
{
int val,t=1,no;
clrscr();
t1=0;
t2=10;
while(t)
{
printf("n1.pushn2.popn3.exitn");
printf("enter your choice");
scanf("%d",&t);
switch(t)
{
case 1:
printf("enter the stack no:n");
scanf("%d",&sno);
printf("enter the value:n");
scanf("%d",&val);
push(sno,val);
disp();
break;
case 2:
printf("enter the stack no:n");
scanf("%d",&sno);
pop(sno);
disp();
break;
case 3:
exit();
}
}
getch();
}
void disp()
{
int ts1=t1, ts2=t2;
printf("nStack 1:n ");
if (ts1 <= 0)
printf ("Empty");
while(ts1>0)
printf("%dt", a[ts1--]);
printf("nStack 1:n ");
if (ts2 <= 10)
Page 1