0% found this document useful (0 votes)
18 views25 pages

CP Unit - 05

The document discusses the concept of functions in programming, including user-defined functions, function declarations, and the scope of variables. It explains how to pass arguments by value and by reference, as well as the use of pointers in memory management. Additionally, it covers the syntax for defining functions and demonstrates examples of function calls and pointer operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
18 views25 pages

CP Unit - 05

The document discusses the concept of functions in programming, including user-defined functions, function declarations, and the scope of variables. It explains how to pass arguments by value and by reference, as well as the use of pointers in memory management. Additionally, it covers the syntax for defining functions and demonstrates examples of function calls and pointer operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 25
Zo Unt - unctions EEE A_function is a self content bleck of _pyoexam l that _perforen. ome specific or well defined task | | program cant be collettinn of these fun tioNs. one a ll function hos been tozitien “a _ perv form particular oct iy can bb: called vepeateslly th. mua wt the_pngram The funtion of its ola [unctinn, The fuicdi cxeated by culled user defined tunctis | hue bree dora. ch tune [yee and tae acumen i functfon Declasation S| of function: | The func tio e devo, th, prototype ‘fon. ii syntax, return type fraction ams feed Eanes ei ment Mist) Theory —funckfon or syste | oyntax « Actined funchi __Ychura _tyee | functian name Cong waent lot); | Lthece E ctined function Teluro_type = “the dat type a2 value shish fa retue ae unc name:- the name af the dinc® sletinedd tion aval i si 7 7 The func “irtined function Thedt Sst defi | acaument " + Name cf the parameter of the ETS ee sil ~ encti porated bi the commas = \ 4 stant iotttan Pec eg 2f you scant fet Hs ta you 4 + fob header a nijude sted. Ti _you woont to Use tuned chet dd fanct? Ht you__must say in the mapiler koi about thi a Neu can de this by ivity nome thing Lied tune a A_tunction connarS pe cated woithout ibs ‘ ebinitio lah jem defined func" docs not tat ‘ aioe = * 5 ogcamme: Sara is gee ee an eg Tee, ia auuilahle be Yctura type function name Caraument list) tng and as S38 ao ut \ nectorm ‘that fash, ‘thea th _pcogrummes lias body; —Thureday Foe 2B (Qi Sa? O) j aie iy Ete t ft —include _(haterich ) A)An asterick has tno _purepases _ticst tor clecla~ ring the pointer variobl L dlata type * pointer variab! date type * pointer variable blcite oc. pesgrain using goloter variables __ at include void _maia () i into | * pty etx = ga: * pty = So: psiatt(* Address of a shun", etx): psioth(“value of a= adi gaintt (“ Value of a = "gts: ; priott(“ Value of a: d\n" (gar), Out out a Pty dices af Q = 190 se] [we] Value of a = 50 “ Value of q = 9° Value of aq = 5° iste a copsagmam 22 diploy the value at E its \ccatian using _esiar a Wows printt Clee" en Vs oak Lf —— t asthe point siariable Th Mowing —dintement pits ptr: 52: will assign 40g aot fulater weciakie piea “mea | : v ogerate: soill_add tocation each \scatinn Ann_oviginal address 2 (tus | of 9. bytes si et i oxithmetic pe rate sith, pointer tlio.’ Ant_num =S0 . * ett, soty2, sete JArite a pointe puri aL oY, pie 2) ‘aod phxds pvt -21 print! nai iers of otra 2 bu\n", otra; 3 include stdio.n = void maint) eB fur rs pie pte ! 4 - aaa Lael Te [Tel Tse | io sama ea , oe wo 280 0000 me ¢nam: 96 printt( Content of ptr ete, menting ?hana ft g prey, pret, pointers are used ith tocvemen?> | grintt (“ Content ot pty ater increment ne UB aecvement ogeratax ‘alsa : i Te | il When the point voxiabl ore incremented) pix == 2 * y fo ae eee decre. + priatt (“Content of Otter decreraent ‘led \n” giz) addye: not ick. 4 — ~ | ‘ Ourout Due of of integer “pnintsr vata pointer variable inceemented then th. Content of pt: Content ef pty atts edo: __hecau the integer vavinble XN raemnmry te _toxe athe clecvement apevatnr 1tfers ts & tthe _addre. not data ihen th. functfon wants ts oa \ : i intacmation tn the “colied funstfan this is * passible theoyah pavamrt: ox argument Ths | oe on ony dey passi, axpument— ve tuncien b= teme > i) print! to tuartisn asap \a" 1: t calling function sent _ print (* num is aad_oumdsthd. S.b)jocu | fn_tho called function | + : | Spikes wean: the value of actual avqument Output { Foci sponding asmal_axqument Bedore siapping Hon -te thi Dum’ = 190 and ume =700 Re Shevnlus cf achial araument ia the I I { Inums = 200 and num =100 { [Aster swapping i : [num 2190 “Gad num2=200 = \ \ uv Junction Call by yeference | Tn col) by retevente the aad £ actual} arguments arc passed. ta the format Orgument: #8 is because the formal argument Conitins cildies #_arival argument, ony chine thet address etfect the valu. ‘ qum2); pRast UEGE oF ENGINEERING, PUSAD Sth Record 20-20 act —— a Fran Ree 291033 : emt 28 foal onntt (Perimeter =f \an "perimeter i Output =a a peenpex Sins - Enter value ct basic salary ee and HRA Gar. Fisoh *p. Host * pd = 1500 Tere es = ae [ive = 2m Biee es aa emniees L— E pier cadius—al—cieshe Teale oc paagmam ts calculate Factor fol toy using esi ~ 4 include td tosh li void jac} i ‘nt number, factorial rg. xo: Nas ve Basic $F ql Fintlide = lok ae) Enter a umber Sal (int bs, int pb, ink bva to ae EL factrial of no. sis 120 gts epiehra _ Return more than one value trom oa function Ba) _xehwn on int that, daublp ee ibang Dean see c_oainkes e_can_get_—mare—thun—one value _xehutn—ab— make a funttion _xeturn a pnrinte | atime f: function using call toy ‘¢fevente — be _eaplicitly mentioned io ah + melnsd of painters dC int ptr, int size) j 7) 7 a - ij. max =o: int rat = {1i0,20,30} {[40.50,¢0} _ { +0. 80, $0} exljea, jasize “y ire) EDD ij ptr array + (*(ptrai) > wax) ee Tm i mox= * (pty 4j)i lude_ a value Tre J Toes] Te | We ase SS alue is 3 bo [The value painted by painter is tis 2 psintey variable int_p20g20- 2: rintt (“Enter a atci gets Coord )< 4jo__demonstvate, gsinter to teh pies coord + ushile Ctagtr J 2X9) 4 past ree if (s sos == 52) 4 hs I ¥ pnatf(“Length of string including space = ‘led \e - ~ < 8): *zpir)s printt (“the printf (“Length of otving excluding space = pirtts } in Output Entor o aixi Sakin pork s engi of string in ‘¢ le gin ok tring excluding pac!

You might also like