Download as pdf
Download as pdf
You are on page 1of 23
7° Selalk ” void xyz0)5 global dectanrahon Void abe ¢) nivold xyzcys % focal declaration pstinke ( Meweleorme abo \n") ; XYZ0} f void maint) void xyz; 4 local deelona tion painbe (“Hello maintn”) 7 RYZO3 e abeu; ~ i ] void xyz) ¢ { puinkt ("welcome xyz in") « 4 olp Hello main welcome XYZ. ue]toma abc utfoome XYZ + ghonage clos - Shovage claser of c wi provides lottosing infosrmal” bo cempiley 1) Stomage onrea of vari oble a) seepe of vertable it in which blotk He vay. jy visible, ce 2 lifetime of aq variable fe, how long fhe voy. evil be Hone In arhive mode, defaalh yolue of a vaxiable if ik te no’ iniKaliged Hh. wepending on the behaviows and storage onea shovage cloyer arg clouified in bo 9: hyped - : D Aubomabic shoxigge class 2) shalic shoyage class Sse Sah w americas = . * EAD, SRS “mee Ey , Uthis stomage class vowiabler wilt be. cwealed asy , o deshoteyed auhomaticalty, Fomaticaly and 7 ® Aubomabic storage clos vayiabley eit be shoe ‘in vback ereg of dake Segment -o;-cpy-egitten. _ : Y under Aufomake slonage clare we hewing & type of storage clay Speeifiou — : t) ano : ~ 2) xegishert . shalic shonage clay — = . 1) Shakic sovigge clasr vaxiabler wit! be caeated only ones and Hyoughau, the psiggaiam i with be Hexe in achive mado only. 3 a) shabie stoviage cleus vor will be stoned in thalic axeo of dala Segmer! 1) under ttakic storage claiz we having 9 hyper of storage class ° Specifiev — o 0 Slatic 3 2) exfoin pas segnen- ° aHen 0x0000 ‘ ca}a aed Heap > Shacls - 3 $e t oxfere Gong) v 7~ C Aulomaljo shabio eS SN auto sity tafe shatic — rhein ee Tipe | Scope | UFE OefAULT Vag aufo body body Grorbage value > skatic Fanchion Pregpian oo exkor, poiypiam Pxrqgotern 0 an eons pgishey body bedy Graxbape value Mole-)Qy defautt any kind of variable sforiage dass specifier ir aulo, D 90 copngpammiqg language Hoe ore 4-Wypes of-Seope ae available € he, body, funchion, progitam ancl file seope, ; ink a, , . shot} ink as ' Signed) shox} inf a; aufo signed shoxt ink a; r rot ‘4 slounge Sign sige Type viable dle gisher, vautiables — 1) gb is q Special kind of vastiable ewhich shostes in cpy segister 2 The advanjoge of oiegister variables axe fash than semaining variably © bevifabions — © when coe one wootking. with siegishon vor. we cart esizak ‘a’ no. of © Sregiskr veotiablay. i.e, depending spon Pu Capacihy 4-6 - aoe ‘ neath urn vaso bles , &) 8M Te-a0 we cant access He addyess of vwgistes variables 3) points) pra pr seelated concep! axe con't applied fo sepisfey Voofiobler. Se ee prgpiaD void mains otegishor ink a= to, +05 Bainke ("nvalue of a prinke ¢ "Enker a value: ray Sea ("Fd”, &a)5 ' --a; potoke ("tn value of 0:74" Q)j gelehoy, fo anpu dala is 50 oulpuk— @soteo, must-Hake addoiess of 9 memory location . éxplan- an scankcy funckon if addsiess is povided for the vegishey © your, Hhen if will give @eton, if add. is no} provided it nosrenally iG wor ke x) ougistor slonage class specifier dust ovecommended fo the eampiley 5 Lo hold the vostiable in cpv sregishy if He mmemadyy tk available, ¢ pa else shoved tn shack 129 of dale semenh. _ Potggsrearny ~ void be) auto ink a=55 +405 painie C™NG= td" Q); oe 3 void maint ~ 8 abet); oe aoe o 7 05 ° G oulpul ase a6 - a=6 CG Ac OFLC ED oufp According fo slonage cla of © Senpe o: seaprichod within he body only Maks why dala can'h be acce in majnes fen clion , © ap SRE i - chomp: Hole: Me Life Kme of the aafo variable is vterlticled wi SR TAS sees Se ee hin He Soy hoa. mony taps why the no. of Keer we axe caltiag the functisry tha} roany Henar jp witt be eoeated (gain 4 gain main void xyz) ink a=105 +t; prinke ("maz xd" a); 3 void maines auto ink ass; tH0; XYZO; RYZUS HOS pxinfe ("Mas Yd" ads 5 up— osu Q.u ast F He auto vortabley ip G AVEO function selabegl Piogsacn wid abot) 4 3 i cutout ; i Catpur— E104 undefined Symbo/ tts tq? point ("Ina = td" ays void maine abew; abeo, pyiake ("a2 4 47995 [pe of He tole ankle eToied cate ree ee why abe function oilaked dalq can't be accers im cnt fat oO P99 stam - void mainty , inhass; clvisosy ty 5 Gurfo inf b= 105 +t05 ttb: PaINKE ("Qs nd be td", abs = J . 2 dp~ sci, declarabion ir nok attoued here : typ). 9 cman language variable clecloxakion should be exizL beyore He fioub stakement oly on else compiley with provicty on uray, Pigsian— void maine) § ink a=10; Gubo ink a= 55 +405 pointe ("a= td” 490); ! culpa} ~ Gsoror multiple declarabion fay fa’ Sxplag.. an ong. Scope only t identifiey can be attowed with ono Specific Name 1.2 if we oe cueatiog momo Hhan one idenkifies w same fame Hhon tempiley wwitt givy an Borax, te mutbiple declaw hion forty . Pag Maen void maine ousfo inf a= 105 § --9; int a= gs pxiolt ("aendvn"a); tro, paiobt ("A= hd in", a); #95 ‘i printf ("aendin’ a): ethos -Puogeam— Void main cy aufo ink a=10; =-a3 Pain ( "a= nd \n".a); ink b= 5; ~ trb; --05 ; patinkf (Nasnd bed bi", Ob) € f =a; PMIOLE ("a= hd" ay; j - a9 output nee bes ast £xp lan, 1) Auloma fic main Seope variable we can occo “in Subscope if Gubseope doesn’) containing fhe idenhifier with came name %) A for Ka Re shancleste) the above prog 10% is e791, be3 variable deelariaions should be complicated bop of the Pxopsiary aftey opening fhe main Scope 5) Aecosding fo. Avs shandard the abovey Praga is valid, bes vestinble can be, decloxed ony whore i> Me Progam abbey canstrweking © body. fexegs\a te void maincy auto int a= 10; THOS PrinbFC "nas 4d "ays penersapesict yok a= ao; Quy inf b=30; +405 pio hf (“\neerd be 7d", 0,b)} } ae +tQ5 pxinte (Mnastd be td", Ob); j auilpuk— Esoierr, undefined ssymbo) *b” Sxplan- when ewe axe constructing the variable dive yy in Substope ushieh can'h be access in main Scope, Hf we ane hyging, bo access Ihen ik give an avid. void abe cs %, inkazs; Shatic ink 5255 $tO5 tHS; paine (“ind td", as); 3 void main) t abeo; abet; abew) - i ovlpaf - ¢¢ c Ft Ge Explan = Aeersiding fo the shorege clauer ofc? tho lifelime of jhe culovertiabie is subsided within the body Phas uly auto lake inks=5; tS; > povioke cuss hd") s)5 y void maines j yzO5 XYZ05 XYZVS, paiote ("in shalic data:24” ¢): } . j colp- Eserori, undefined symbol ‘s Seplan- 1d when-we are working T the auto vay, scope oy life time both cate Hésfaticted) within Me body . 3) when we ae working W the stahic vow. stope is vierhaicled within the quaction buk bifetime tr nok steshsiched, 2) 9 imple, when we need bo accer @ vax. in mare than one Hren go 4a exkrin vortiables i. global vorriables ane sieguic 0 cohen ewe axe working with He global vasl. scope on life Hime both arte nob seststiched , 5) whenever we axe declaring a variable outside of the 4 tiockisyy then ‘ik is called globa) vairiables. Lrgpaw- inl gs 1 globa) veoiable w void abe O f +t; } t void XYZ) ° 2 ; us 5 void maint 5 i , +8; € 24 ee is i 9 ene cae ema vastiable will be creoled in eee Jordin call “ > D slalic vorioble will be cxealed only ney when we one call the Junction and Hxowgdal the vay coil be exo in active abe only « Paegnamn - void xyz¢) a auto int aed; ; sabicint ss 1 default value xp stafie"o” 5 es +e; tts; : puinke (raved td" OS) 5 ; io 3 : e void maine) € f + C x20; a “¢ KYL S C XYZU} : c j ° ouhpuf ~ a) * hpuh a ’ aaa . explan- by defaxl Hre valeo of the shalie vawiable is ‘9: ieee nok inifialiged if- o . rogram . void abe ty void maingy . oe slalic ink s = 10; abe o; C € . abet; e : ee abe (0; S puinkt ( "instakion std", 8); | e & static inf s:20; olp = slaic n 2 ; Roce slatic @:ay 2 potinte Cninstalic a: fd".s); Shobied: 2 * a Slalicx: a2 ; Shehea 3 & 3 Shahiea: Jf iG i¢ CO o f oO” » kyz0) & maint benetigy we orgulored fo go fo¥ forword declosotion of global vax. in abeo, xyz0 & maint). D gn implementation cohen we nead fo declare q global variable mane Han ones in place of decloxing. multiple placer viecommended ko ao fox glcbel daclaxiation of global variable, a) ashen we adie decleoiing a global vaxinble bop of the pyegsram before defining he fuk fanckion Hen it is calt global decloxation, when we ono declasiing a global vewitable in globa) Jocation then i} 9 jr nof aequisied fo go Jor local declaration, if Me local declaration _ is available then glebal dedoatien will ignae Saluhin- extoin ink @5 1 global deel a>abion void abcwy ; nexbein ink gs” foca} deelarahion 8 4 void 720) . nextorn ink g; 7 local deeloviahion “8 $ void maine) negkerninkg, 1 [eal dectonahion --§5 abe; XYZ; pink ("In ge ha, @) 5 i ink = 10; olp— get ee iz oe | Ee om toh gs declorafion void abecy f Trg; g void maine) , as abew; pxiokt ("gs 44" a); } output C109 undefined ssyenbo) “-g Hnking ) Explan- 1) evhen we axe working wilh he globa) vaxiable, if the derlabisn shakement wil] hop available compile wilt giver Sony, at he Lime of compile hime evion, 2) when the dafinifion of He glebal Vaxighle i ne} ovailabe Then compile will giver linking BOLO, 2 prgpiam- ~~ exhenn ink g gtoy/ deel bios) void xyz0 poioke ("gs td" gps rakes @ defini Hen oulpub— gel fyplan- nthe inibialigahion of He global vaviabje can be placed in Aeclonsbion ox dafinihion sta henenk. 2) whan phe dacleorabien past}: eonfatn inika hs abion Hen ih it not sesyubsied be go Yl oetinibin beg phys mermargy wit be c3709 hed t ya dedastXHon shabemen b, OC 0 Q2000 ° ne Paley MEST Sy Hie Aba SERRE RSS HT Ff PE. wis. the delini on p compiler will \gootie definition shaheme nf. prtegean) ~ exfoin ink g=5 void abet) +85 void maine) 5 tg) abet); poinke ("ge hd" Q)5 3 olp- at c _pte 1 = oar 11 declatalion Ciniffali. in ded.) v “calling Convorsions ¢ v expoin ink g=10 void abe ; +8) 5 void maint) { ~§s abet); paint ("gs hd") 8) 3 ; ink ge55 7 Stet olp- g= variable ‘gy’ is akin in definition inikialiged mowe Han once, eras on implementation whenevey Me feet is sequined ony patamefes Men Os aq progxammey ik iv wy esponsibiliby “he maeaonedl the Sequence q poramebey oreahon ke, lett Jy righ ay tight bo lelt. calling, (owopions ove clerides Hof in which seguence paxiamefoty rete 2 Sa eran es = I ped fo be Heap | etree tara £3) in C-patogsteummi language Mere core 9 hyper o Vf : axe available 3 ae "'b Convexsion ts edeet (ede!) calling Convertsion 2 parcal (pascal calling conversion, 1) cdeed calling. Convention - gn His calling Cowextion paromelerr ity be sexeafed foward: from aight be left. = This catling Conveision is a new fechnique cwhich if Available in all high level pong oramseiigg languages - = when we are woriking with cdact calli the quoction name in lowe, case, — By dejaull any function calling, Convention is cdees.- 2) pascal canting comontion— 99 pascal calting conversion parame toy wit) be csieaked fomarde prom lope to wighh. - this calling, conversion ig a old Kechnigue which is avatlable in data. base progeiameni like pe} sQe block in oracle, hen we ate workiqg with parca] calling Conv ewion, qvockon name siecomsended place im uppor Case, 3 ing Cowennion. dtecorimended to place > 3 Qo forme] wpuments, arial vpuments — eee tenes C= 90 qunchion headey ov in qsinckon declaratoy, ushotevey Ihe Nala wotiabler we ane creating those axe called paomebens ax Ay onigamnenhs. 2) 8 punckion calling shakemenh wha ever Ihe data we one pas tho ore caved achual cxgumenfs a7 samen} s, oh 3) gn omdenr ho cat) any Juockion tf Th lr steguisted OM Ipectfio number of paramefan then we can'k coll hhe funckan with ley thay & on mose than stequined numbet of parometeny - Nolen where the implementation posit of Me funchion irgeven ih iy 2 called pantheon definition ye 2) an function definition fos} line is called funchion declaatay ay, qanchion header. 3) ashen we prioviding the lype Infotmabion explicitly io the cornpilor Fen ‘ih if conte} declore Hon. oR STE dea hea a ape ~ uy adel ype infarimakion of He powomefer., pager eae oye faoimal aguenen}- void edect obe (inky, inky) 1 qunclion declarralon f ao puinbe CWO x= td 9 wd MY)S moi cdee} void maint) LeR iF obeC +40, 074) y inka a=105 arfual agumen|- | abe Cr, art); function cling e,, pink (mas td! a); © j oulpuk — X=12. 4210 : a= o _ ftgpram- void pascal xy2( inh x, tahy) pasea} ‘ , miro LR prinke Cmnxsnd Yord' 4 9)5 a fed | o- : void maing ey i f ink a; | fray a=103 0 ayz( IM, 45 [eee eX ‘ pointe ("nas td" 0); Ce] ‘ j ovkpuf - X= 10 yal? aig pesjame ber passing. Iechniques— Ly SN. C-pmgptameing languege Pheve oe a-bypes of parameter, fousing fechnigne ove available - v call by value 7 pair By Value ay call by add/ pate by addviex 1) cathy value | pass by value — ~ of is q concep of calling q function by ecdling value pasting. fhe value ype deta fo q function, Y Whe Mpeclata oy = 9n call by value ackial orguments end formal argamenl- bobf, LOG ane yalue fHype, — af any mockificabion xe ocewy en Pooimal augument those changey wilt BE nof affeched om actual ogaments — ” Ex, poinkeey, powrty, sqotkey, ose, fmodey . a) cat by addyess / pass by addseyy — — a is a Conceph of calling the junction by Sending addsier lype daha, 0 passing addyess “type dala bo q function , = gn call by addviess actual arguments axe addsiess ype, faxma/ axgumert, one poinker lype = an cat by addyess if any modificafions axe ocews on formal oxguments fhose changer will be a jfeck on acktal oigumen ty, EX. Scankey, gebser, shtepy ed, Shreve), memsel-cy. Nole- : 90 C-poregorarnmning language Hewe tr to. any, concept axe avai fable with the name called call by oieference . 2) Oat by veference ig 4 COPL fubwre coith wowks with Me help of oiefetence variable. 2) 9 Cprogoromening languge vieforence variables axe nok powible s. call by aieforence mehaniseo ie nok available Prggom ~~ void Swap () = pointe (Mnazted b= 1d", a,b)s $ [> wrod mau 0) int abs azl0; b=; gwap (a,b) pyinke ¢ "nas ted b= hd" Mb) 5 a j oubpu— sistas, undefined &ymbol ‘a! *b! teplan. — According, ho fhe ut ge claser of 'c' Gand b axe arho yawtables which is Constouched wwilhin the main funcHon so we Seanth access to SuapCr, bey Stope is vrestiched within the bey Program - : votd Swap Cinka, int b) main ‘ § E ink b5 Peel PR « ee swap (4b) 5 £ Q=b5 4 > beh; Swe painke ¢Mnin Swap a= hd bed", Ob) NS [ae IT 5 _ pel Fs) void mount) &) I § ink ad; TO Q=105 b=205 Sevap (1b) 5 pink Cn tn main etd b=hd" a,b): & ; ‘ ; . sulpuf- in Swap 9-20 beto im main axto b=20 . ‘ ( Sxplao= 1) an above prrogriam Swap function coi! worke with the A holp of calt by value mechanism Hats ashy no any od Hea hion & of Swap qunchien can be cowmey bark. e [Sao pte oearIe Se eT Rip nen WE ee: for add, mechanism . orn Hon 7 ‘paid Program void swap C int pt, inks pa’) main a fs fe €pL; a hea; ®p1-*Px; Wa=b; «Pats on beks Pouinke C\y in Swap a= td betd", pt, FPR): 3 void) main () inf ab; 5 A=10; b=} ° Swap ( &a,&b)5 PHF ("In tn main Gehd bed", 4,9: ? oukput - TM Swap 0-20 b=19 MH man qe beso apes 4 above unclisn preg cSunp funthion eit) wavy coikb the help of ‘eall by add mechonism thals why ait modification mf the cuap fuockon wit be apeeled fo main Yunckion jnk a=t0, b= 20 | ink azto, b=20, ¢=30 | v toh 0210, b=20, 6-30, devo + Qs Otbecs | A= Atbregd {qs athe); hs a~ (breed); | b= a-tbte); | a. (brerd): © ajo | te aCe) | B= a- (brepd); © a b | Qs a (b#C); \ G= a- (bred): a we Slp- 30, b=10,¢220 OIP- A=40 b=10 Cz20 dete a i a b - / AR) G5) &&) | BB) Te % id yo 10 30 [eens ea s1000. SSG EET ae int powey (int b, inte) ___mah 4 “ Ee ink o= 15 [a] (s] ff (ag)? '? sehaxn o; for (ist; ise; et) P= power (ib); - or of #5 — veka 315 5 void maincy power be ink aub,p 5 [a] [3] claisen 05 rs exinke (“Enkey value of a: "); VSS scant ( "xd" &a); pHinke (" Enter value of b: "yy ScanF ("xd" &b); 11 P= pow Cab); P= powes ( Ob); porinke ("a ndAnd value is: 4d", a,b, p) ; gekcb ty j oulpub - Enbor value of a: 2 énkey value of b: 5 5 value i$: 92, 1) Rehoin is a keyword ushich is ase it bo pass the Combo! back by the calling locatign with axgumen|s oy witbou} ang uments © Ay Using srekusin sfatement It is posible bo ae fein ely 1 value : ata hme 3} @y using function srehwn ype we con oiebuvin orf & vel, . ‘enplemenpakion when we need fo viefurn mare then 1 value prom q © Junehion tren sessed fo go for call by oddirey, 7 4 fly wag call by addsiess it Is not possible 'o Hehn mano \p than one value buf tn place of velwining we MH paw book [S{PoR ee oe eee eee 5) - quoction we can place ang numbey of siekssn statement bul af the Heme of execurion among those alt only one sete con be executed. y chan statement. pagquan- ink max (inf x, inky) | ‘ if O0¥) otefun X5 else otehusin Y 5 3 void main ¢) ‘int ms oO m= max ( 10,20) 5 ~ pxinbe ("sn max value= fd", m) 3 j oulpuk- max Value = go Porqguaw- (Fac bosvial number ) void maine) s tes sutpat — faker q vale: 5 Ir ink Fock Cink) ; Fock value is4 120 clusey 0) 5 pyinke ("Gober values"); Seanf CN Ad" €n): f= fack(s); . prinkk Crwntd Fack value iss pd" © getchd; 3 int Fach (ink ny SSE pa HE RUFC TRAIL MESSE BG RR shen the qunckon xebwins inkeger ond faking. Hype iv oho, Wan fl Hen doesn't stequisied fo @ fe forward declwation 9) Accouding Fo Ans} shandarid fre above PHogsI0m by evtox by toherevey we once colin. function usbich ts define lak 4ox avoidin He CompiJahion evioy we vieguined by go fay forvaard declavahsd % > ink xyz Cio}epd, ink +p) 1am - ink az[o, b= 20, ¢-30; at=Q5 // A= Qk; ble=ay b= bia CH= ata, C= CHS; pe b; R= a, siefertn a) : void main os ok xy, 2; x= xyz (hy, &z); prinke ("xen yond Zand" yz) 5 geteh oy 5 culpub— -ys19 yzin Zs 35 Recwjsion; — - ction calling it self ic called secunion odvantage — ; » Farchisn calling selaked infowmahon wily be maintain by secwuion 2 stack let wait be fake place by Using stecoision 4) iq fix, prebix, pot x relations with be evalu fed tp cui deeurtign

You might also like