Professional Documents
Culture Documents
PSTC_UNIT-4
PSTC_UNIT-4
Funetions
Mntax
Functon defrei
Function call
Lretun varlable Cualue)), Function Probtue
Tese are mut
and shuuld.
on
o e f i n i t i o n
Function
Void Sumc
int a b , sum=0
void ainc
prirttC"Hello"):
SumC F u n t i o n cal
Aduantage Lunot krA
3 eeuabil
to the
dehug the muam.
a t ' s easy
)Better Mem0y tilizatfon
utilizat+on.
A) Reduce the complekity o prugram
'nt a,b, s
int a, b s
Ssubstraction Ca,b)
int a, b
Printt cmultiplication y, d multC ): s
int mutic
diufsionc
void druisson c
tnt a,b 3on
printt Ce ter tuo inteaers n") om6iou
SoanP- C /-d . d ", Ra, ib),
Note
Potocol Prom examyples sooed
Tndirect Reeusion
Pun 1C Pun2C
PunRC Punic)
i r e c t Recusion 2rs
mainc
tunc )
L un c
Punc ) -
3
Advant o Recursion
isodortnges r
reeds to naintain Pollow the staok
E
DEis more comple than while & For lcops
Aactoial n
SxY32xl
int mainc
i n t num S
no t o
Pind factorial: ")
pintP C Enter a
PacC4)
Recureion.
sum d numbeb
t mainc)
int numi
nunter ")
printPC t e
o
5+um Ca)
frt Sum Cint n
t +umC3)
6
Tetwn n
urt 3 +SumR)
else R +SumC
return ntsumCn-1)
4+SumC
o
power a number L
i n t mainc
2int b P
printPcEnter base no=)
retun 1 atepl
else 2expa
1
retwn *
ep Cz,{-
,)
*tageaasGeS
*Ex Fibonace Senes u
int maínC
int , i,Y D,LI, , 3, 5, 8
printte Enter a no ")
scon-Ca", Ln) blO retun o
For Ci=o len;i4+) retum 4
gd Cx
int gcd Cint x, inty)
int 1/1
PCr-=)
return 1
else
return gcd Cy,
3
storage clasees
d i c a t e s
Etern
statíe
Register
storo Scpe pefault Memor LIfetie
elass Value Allocation
CeccesS)
OAuutwmatic Lit in Grar boge k e Bock
vavfables Block valuess RAM
loc
l u o S start with
Tt reduces te
comdexitH Pgn
E # inelude
defire
#undef
d e
1P-ndeP
elbe
elif
#endiP
#pragma
# ev
Fdafire er2e
tntt arr Cstze]
dePine PRINT Pintectai elcome
PRTNT
deine AREACa) C3-14elS
Ca-1ls*aa
Void moun C
un def-
#wnd et NUL
dePine NULL O
i deP
H iP deP NoLL True
#undef NULL
deline NULL O
endiP les
Hetit
For multiple conditions
Pro9Mo
Directiue used
t i a special Purpose
b
on or cP Some featuras
tw
t urn