0% found this document useful (0 votes)
5 views11 pages

Stack and Queue Operations in C

The document contains code snippets for implementing stack and queue data structures in C, including functions for push, pop, and display operations. It also includes a recursive function for solving the Tower of Hanoi problem and a factorial function. The code is fragmented and contains various syntax errors and typos.

Uploaded by

abhishekgolu2006
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views11 pages

Stack and Queue Operations in C

The document contains code snippets for implementing stack and queue data structures in C, including functions for push, pop, and display operations. It also includes a recursive function for solving the Tower of Hanoi problem and a factorial function. The code is fragmented and contains various syntax errors and typos.

Uploaded by

abhishekgolu2006
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

+ incydc <stdlbh

int stoc[Nax]
int top-1;

Vo'd pushf
int val;

PÖntf( nETt Vlue to pus h:") ;


Sanf (% val);
toptt
StK[top]= val;
Pitf yd pushed to stocn",
val)

Pintfnstock Underflown");

Stock Etop J)
PTt ( m PoPPed from stocu \m",

1
1
yoia diselay U{
if (top ==)
P7intr('n Ste is emPE \n):
prjf("n stock elements aTe:");
for(int lz tP:i>=o;i--){

Pinef ("md;

It main )
int choie:
while (4)
PittC'n\n---Stocu NenU - ---\n";
Printf "1.pUSh1n ");

printf(u 3.9jspby\n;
PrintF(" y Ext\n");
print" Bntr"yovy cho'ce! ");
Sconf"sd" A,choce)
sutch (choice) 5
case 4 PuSh C): bTeak ;
Case 2 ' PoP () break;
CoSe 3!

Case ! exit o)
defoult : príntp (\nTnvad choke \n):
2, wA: p fo TOeY 0f Homo to dís Plog the move ment 0f dsk
Ond alsO dslas the wrnbey 0f teps. Tole n t f7orm Usr.

#inluac< Staio h>


+ hclde <mathh
Nojd touY( inn, ch¡r be,ch¡r avx, Chor
end{
if (n==1)i
Prts("Move disk A fom .c to c\n'bca,
end);

towcr (n-, be? end, avx;


Phnt+(Move djsk ya form c to Yc\n n, beg Cnd)
tower (nl, aux bed, end):

it n;

Scon "0)
Oit* steps to Solve the toweY 0f Hon0) w)th Yd dise
tower (n, bes, aUx, end);
PojntFtal Stees to solve the toucr is Vd:" (n)(Po(n)
ZetUn 0; -1)):
DUtPUE
stees to sve the toweY of Hono) wh 3 d'sk Tot d'sk to SoVe he
Move dsk 47oM x to z | Mwe d) su from y to x toY s
Mve d) se froM x to Y Move di^u fr0w y to z
Maue dis fom Z to y
Move d)s
Poogan to olaate foctoa 0f a umber (
toe inPUt from ÚsCY.

inchse <stsj0-h>
int foctonal (intni

}else f

int rainuf
jnt mum,
Pon Entera number:"):
Scanf(% 3Urm);

i s ( Fac+on is not defned fornegative Dunbrs


inoledioh>

Ina quuplmax}

Ind

|3

resn 'rears= man

vod engU Pue(in4 elemen4){

QU PU Pl reor erement )

ptne"ueue ond estlg an4 delede eleme -\n);


reBun
pIntf deeetf% trom tQ queue\n, queupCArond
J) ;

front reat -f

vord duday
pannfan");
tht morn
n! choc,elempnt;
whlelt

eAqUrup emen+l

dup lay) ; break;


enthng pragrqm \n)
tel cn ,
pin f[lfnvald ehoteel");
relun0;
tncludecNd1O-h>

mox l00

In! pvalua! fporAfi (char # eprl

In! operadI 0pAand 2, reol}

(ortnu)

Op erand)= opi i
COse /':
if (operand 2==0){
Pintf("owision bs zo ror\n):

DLSVE - ORIMA 2/orm 2


brcok
defwtt :

oItl1);
Posh CUE):
I++;

Por C

Chor past/PE loo;


PIn"Ea a psx 6AeS0on ( sindo -dy Ogrms n ): :

coUateputfR(PAKE),
Hno;
COde:
#ncludc<std)0·h
# inxtude < tdlbh
+ defne Size5
int cals)2c J:
int frort -4, Yeor ~1)
vojd tnscTt (int va)
if(font ==02aT== sze-))1(font = : 0r)
Printf("
(front = -1)

else if ( VeaT= S)2e -1 2 470t =0){

CUear J Val

Void deletrO{
if (F7ont -1){

n
Prjdelcte

sizr-V

font +t;

void diseoy ()
if(frot ==-1)|
prinf('eve i's erppts

pritf"
c r qveve enemen+s:)

("a" cAUJ):

for(i=0: ic-0r; itt)


Primf("", cac3):
in+ Chora, Val;

IiDt(" n4jnsA\n 2. delee n 3-diploy n 4 exst ):

PR "E Vall to no"):


ins lya);
dettn C); brok
Cofe 3

breax

You might also like