You are on page 1of 12

Page No.

Date: _

Name :Awatade Rucha Dhananjay

Prn No 201a0325000 50836

DSC DatastTucture
using CET

include < Process.h>


#include conio.h>
#include <iostream.h>
detine ma lo0

ClassStack

int item [maxl,top

Public

YOid Create (Stack*) i


Noid Push (Stack *, int)i_
int Pop Stack *)
void ismpty (Stack *)i
Yoid isfull (Stack *\i
Noid Status LStack *)
Page lv
Date

Create Lstack *P)


YOid stack

SP toP-1

Caunt K \ n stack is created..

iht Stack PoP skack *5P)

CGunt K" \n Stack underflaws"

else

return LSP> tem CsP->tor --


Yoid Stack Status (Stackr SP)

inti

fori SP top i>=oi--)

Count L<°\D K SP > itemCi3i

Yoid Stack isempty (Stack tsP)

iFSP toP =-1D

CauntKK" \n Stack is Empty

else

COunt <<" \n Stack i s not emety

3
void Stack istulL( Stack
sP)
if Lse-> top-: max - 1)

Count K*\n SBack is Full";

eise

Caunt KK \n_Stackis Not Full

Yoid Stack Push Stak SP int 2-

if CSP toe : mnax-))

Count << \n Sta gverflows


Page No.
Date:/_/

else

++ SP topi
SP- item Cse>taP): xi
COunt (K" \n Fle menti s us bed

Vaid main U

Stack obj i
Stack *P

int nn thi.
clrscr i
do

COunt <" \n Enter your choice:"


Count 4K" \n 1: create \h2 check For
Empty n 3: check for Full \n : Push
AhsPOP \ n : Stat us \h7: ¬xit";

Cin>>chi

-
Page No
Date.

S t c hc h )

Case 1

Obj CreatelP)

break

Case2

Obi. isempty LPi-


breakL

Case3

obj. isfull (Pi


break
Case

Cout K " \h Enter ány bumbfr " -


Cin>> D
Obi push P, Dn)i
break

Case S

obj PoP (P)


COut 6" \n Po ped element "K
break
Page No.
Date: _I

Case 6

Obj Status (P)i


break
Case 1

eeit o)

3while (chl 1)i

9etch( i

I enc ot main )
Page No.
Date

include <Process h2
tinclude conio h~-
E indlucle CiosBream.h>

5trucE node

i n td a t a i
Stuct hade * hextE

Structnade front NULL


Struc hodle *reaY NOlL
StTuCE hode t teme

voi d Insert O

COut &" insert element in queue .'

Kendli

Cin>>vali
if Crear-- NULL)
Page No.
Date

ear CStuct hade t) mallac Sizeof (S truct


node D
rear Dext NULL
rear dat9 val
f r o n t - reaYI

else

temP (StrucE node *) malloc (sizeo F(


Struct node)

Yedr her temfi


temP data= vali
tem P-2 nert NoLL
rear teme
Dete

void Delete O

temp= front

ICFront NOLL)

Count < " underFlouw"2ehc;

retun

else if (temP- hen+ NUL)

temp temp next


Couat ele ment deleted from 9ueues
LL front2 data LLendli
Pxeefront)
front E temp

else

LOuet Z element deleted " <


ront data <<end
Eree Erant)
front : NULL
rear NOLL
oid display O

+em P front
ront : NULL) &2 (rear-= NOLL))

CouAt << Queue is empt" Kendl


retuYN

cOut" ueue elements gre ";


uwhile temP | : NULL)

Cout k t e m P - data <


temP E temP 2 nert

COunt LLend1
Iht_main Q

int ch i

Cout < 1)insert element to queue Ler


Cout < 2) Delete element *ram queuel
LL end
Cout i " 3) Disely elementS "<en dl;
cOut LL " 4) Exit L enclL

do

COut K " enter your chaice 2endl

Cin 2> chj

Swi+ch (ch)

Case1 inSert U
breal
Case 2 Delete ()i
breal
Case3 Diselay ()
brea kj
Case Cout 22" e xit ''Lendl
breale
default Cout " Tnvalid coice Leno

hile (ch =u)

You might also like