You are on page 1of 9

RlRc.

T,CRL No : 4

_ _ __.._ Tue.a~~ :
~u.e.LlQ... : _ _ _ _ _ _ _~
1---- -.....- -- ~LJ.£.l..LCL is CtX\_ a!nde:ne!.d c.o\\e.c.tic n Dr 1tem s 'u 1
\ WV\l(.,Yl e.le rf,P_f,}~
~ ~'te d j~a..M ..ot\.e. end Lc:<l\ed KcAR o ..nd c.klerr-O 7--~_,:,{f1
_ _ _ _.._.(l..uOcuC-:'1..1..1½..uf?;;._,,"1~ ""cJ.\.e.d t8'Qt--CT _ ___
~l.lf! 11 e --1½?\\ 01 us fu? P,o/1 i oc , p.k_-o.} - __El_F 6_ -fuo.I 1~ Ji~-.w. 1 f\+ - -

CL. 6 cl c\ e /

t 1
fnont: C' ,, l.)\

2.
)
_I,,
D 2 2 () I

Q b Q b C
o,
-71..Q.OJ\ = j
- - - -- -- - - - - - - - - , - - - - - - -
?\JLW

CH r J 9jJJ.~ lf\Se.J't Q.
C.

Fo"'t < o
--- ~~ e.~CV-1/~ u.Q., ('J'P
), I(

i------ --.....- -,--,1" --....-~ ~=~-~ ___o_ _-+-_"J__J,. - (')--.-- .-- -,-
~ !

J Y' p
_ _ _....._..;nqµ.e.u..e. ope:n
CLb.o n
t---1 +-Sre p 1 : in.1\1_Qt'e. J~ool:: - D , .)ieW\ =- - \ y.,.ocJ M/\ 1/. Ll'""Je.. -=~-
___ _s.+ep 2
: c.he.~ if qµ.e.l-le. lS fu-\ \
3
-- if .::ne.(.L)l = = M A x
-- -l - - - -
Ste.. _·. IJ ~e.. 1·'=> _ful l .Jthe.n pro-\'c'\t .DV£~Jlo.w Q.:r-'10v1 cieid
1...-- ----+ +---- -.exil :\h_e._ pu1D:j 'nO. 00
1----- ~ -) ___._
4 __ -4- _ -9,ue1,e \Ei ~ L ~ . . e n l ~ ,...,___--t

Sre.

tf ±be ovlde1u 1s ao+ emp:\-j , ibe a p>1'1'.)t ___ __


ih!!._ .e\ eroe 1\t o f\d iY\ c'5l e rM e, V1t tb e _ -J:n.an.....____ --1

dm = ~i.ULJ---'10.nLi - - - - - - - - - - - - 1
J.:iioot- =- J.:non b + \___ ___ ___ ___ __--1

0 .

p:n a.c.hi.c:J...,\ 1 w e.. hc:ul.~ \e. D..i:\'nec\ \he.


1-------......u.i~~,1.1J,,411~~ '-\-'--1i.ne.u.2\ ~ ~ iA~ c.J3 a &i; tbm c:1.nd
C: \Users\Linza\Source\Repos\queueimplementation.c 2
{
51 if (front_lnc = -1)
52 front_lnc = 8;
53
5ij printf(•\nEnter the elenent you want to insert in the queue : • );
55 scanf("•,d" , &itea1_lnc);
56 rear_lnc += l;
57 queuearr_lnc(rear_lnc] = ltem_lnc;
58
59 }
68 }
61 void dequeue_lnc()
62 {
63 if (front_lnc = -l I I front_lnc > rear_lnc)
6~ {
65 printf(•\nQueue Underflow\n" );
66 }
67 else
68 {
69 printf("\nE\.e111ent deleted fro11 the array is %d\n" , queuearr_lnc "'?
(front_lnc]);
78 front_ lnc += l i
r >
7 }
7 void display_lnc()
7j {
7 int i_lnc;
76 if (front_lnc == - 1)
77 {
78 printf( "\nQueue is empty\n•);
79 }
88 else
81 {
82 printf( "\nQueue is \n• );
83 for (i_lnc = front_lnc; i _lnc <= rear_lnc; i_lnc++)
8~ printf("~d " , queuearr_lnc(i_lnc]);
85 printf( "\n");
86 }
87 }
C:\Users\Linza\ Source\Repos\queueimplementation.c 1
1 j <stdio . h>
2 J MAX_LNC 5
- void enqueue_lnc();
void dequeue_lnc();
void display_lnc();
int queuearr_lnc[HAX_LNC] ;
7 int rear_ lnc = - 1;
8 int front_lnc = -1 ;
9
1r int main 0
1 {
12 int choice_lnc;
13 while (1)
lLI {
15 printf( •l . Insert element to queue\n" ) ;
16 printf( •2 . Delete element from queue\n" ) ;
17 printf("3 . Display all elements of queue\n•);
18 pri ntf("q .Quit\n" ) ;
19 printf( "Enter your choice : ") ;
28 scanf( 11 \d 11 1 &choice_lnc) ;
21 switch (choice_lnc)
22 {
23 case 1:
2q enqueue_lncO ;
25 break ;
26 case 2:
27 dequeue_lnc();
28 break ;
29 case 3:
38 display_tnc() ;
31 break ;
32 case q:
33 exit(l) ;
3q break ;
35 default :
36 printf(•\nWrong Choice . Please select a valid option.\n" );
37
38 }
39 }
q9 }
Ul void enqueue_lnc()
U2
q3 {
u• int item_lnc;
US if (rear_lnc = HAX_LNC - 1)
U6 {
147 printf( "\nQueue 0verflow\n" );
us }
149 else
ii De.-doptt Cornm,nd Prompt fo, VS 2022 - _,..rnpl<m<nUIJO<\.ett X
ii De,,Joptt Cornm,nd Prompt fo, VS 2022 - _,.,mpltmtf,obO<l.elt X
ii De,doptt Cornnw,d Prompt fo, VS 2022 X
0 \ '2 3
\
..{\""
fJ'\C> t'\t
0
'?>

2.
/i\ ' /i\
F')\ot\t .:1\,e.CJ\

0 \
"1orlt

' ~ ◊\}1\ 5 j
l' ~
t~~V\.t; ..>-t..e.A)\ ,
- - - - - - - - ---1

__ f~~~t ___~
Jvlc-lh - - -- ------a
u..._e:\;<L
---
l,.I.., e
\· ~~ \!.1:1\.._s l__u__~.u;....u.----1
f Zn() 'O·
~ ._ _Ll.µ.SU.,.U:..--l..LLLUI~~
utfCV\

You might also like