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

C Program Ass 2

Uploaded by

pottipilla068
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)
47 views11 pages

C Program Ass 2

Uploaded by

pottipilla068
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/ 11
MADANAPALLE INSTITUTE OF TECHNOLOGY & SCIENCE Ot Rey (UGC-AUTONOMOUS INSTITUTION) ay ~ Alfiiated to NTUA, Anantapur & Approved by AICTE, New Delhi NAAC Accredited with Av Grade, NIRF India Rankings 2021 - Band: 201-250 (Enge.) NBA Accredited - B.Tech. (CIVIL, CSE, ECE, EEE, MECH), MBA & MCA Department of Computer Science & Engineering Assignment Submission Details AY — 2023 — 24 Subject: CORE /Open Elective / Discipline Elective / SOC Subject Code: 23CSE101 Subject Name: INTRODUCTION TO PROGRAMMING Name of the Student &-qyo hn Roll. No. Q369|A0574 Year /Sec 1- CSE - B Sec “ATL ‘Assignment No. Marks (**Max 3 Mark) 2 ‘Assignment Moodle uploaded Date | Uploaded // Drafted - Faculty Sign with name & Date | goy.Chaiper-Hhamed psa s 7 T>4 Unit 3: Ql: gegplatn any Pre staking handleng -Runctfone ufith eztample unitsq2: How woul you diPRasentiate the uses deRred chia types, etouctune vith unton!? Gxplafin with the oPa aittable example. mania =r Unit 5: Q3: Wat : a ca & & pagoam ha, Seappig oF bwo 7. chary4 the value oP. a voafable ust pass y value and pase by ReRerenae, a Assignment: J eee Berphain any Re Sting handling -Punetione ws stsfing landing -Linct Fong he ee ee tt “the paectltnect -Rinctiong which age deeigned “10 honelle Pefigs of avalable 77 the {hoon atstip- hn! wih e2tornple. ¥ stolen) 3= “The, -Punction geluans -the length oP he etoing, Baample t= stalenifarne); hig will Sebuan the kength oP the Slstirg Sloged mM the vasfeble ramet). Lt ata cat (= “Thee -Runckion Concaterotes —heo slsigga. Brample = slacat(rame mame); This wil concatenate the steing2 Slosed fh the vastiablee nomeLJand hore] th the oadleg fn which ¢} fe voaftten. ae Slacpy07= thie Purction copieg the value of the second Sleting -to the “Pract sising. Exornple - stecpy name! rome s ahi wilh copy she | Staig en rome -to She Vasfiable name!CJ. | a : © | > staompU- This Punetion co¥piies “00 Stefigg ¢ | Baample ~. slacrrptrame mamet) 4 This competes the | | elefirg th romeLJ with the Stating tn nameil). Tt geluang 0 iP the Staingz ame Same ext Jelvang a value lessthan 0 4P rameCI +0 loweamge damp $ sislioa(name; r+ shall conve the whole | Slofing Stoaed in he vaafobe namety-tp lowenca ge. & | | | | Me baley lergth B= stalent)-funckfon- : , Fi okey facton aeluang the legth of the fren hig. xt doesn't Count null chonacten “NO% 0) = indude (At dlio-n> i = fnolucle < sheng shy fnt maine) chaa rame C J= “Hello” 5 fot lent, leno; len t= StalenCname): len 2= Salen CYeily wold "95 Patink? (« leroth oP ee= gan": pare , ben Ds fr " | aoe. ° ae oP shez Yodo" "Hello woald |, len Pe Outp te , a i Ue } ean ot eran Na | Coy, seg: oy? | Ft ts fa. copyfig Sood Stefing into destination slain hypothe length oP the ckettralion slaty = So0ugce Stateg, \| ms= | =Hirclucle tinclude Tot main’) 4 Seco statis and ~fwie out fot 4.52 i= Stoampcst “Hello "97 KA wn Ann" 4405 ae luan 0; 5 a Outpube he diPfesence behween the factt Vahee bP NOD) and | W(@) ig -5. @ Fow would you ie dating lowerrase tatalwac) ~ Lp the Slabwoa(etsirg) -Aunetion aetuang lLowagcag e- Paggeom 7 =H inclucle Sint mance Choa Statbo]y Point? (“Enter elaing:")s geta (stad lloeads stating Rom congole patot? ('stefn tg: %9"!,Sta)5 pafint? (Nnlawea, Stsng B+ 68 ‘Vatsleoatst>); geluan 0; ¥ Output s— Shteq Stsing MILs wea stating IS MILs Z lawes, slag ig nite A isfRepentiata she user dePined chto types si Se with union 7@epatin withthe help Pa Suttable example: PPReoence_belween Staveluze ond urfon {0% mM unfon we can ony eortialtze the -Pragt data membes whegeag %n a Stouctuse we can initialize rrany data Trembeggz at onde. # compiles allomteg mempar Ra each membes of a Stoucluse Wh? le -oa a unton rt allocates @gual to the size of the loogest chta rrembea- using chogacleng, * Toe = memes location while Praia roman ye ale aca in — » eloucluae we Gan access andi ual membegg Simultaneously whi RA a Union ewe can only Access | OMe membeg at a time: | spaP we change the alte oP a membea tn 4 Stauntuze, FL work afeat PLE cthea membeas bub to a Union, eg the vaie oP pre member rotlt affect the AZ. - |___Slauchise | Lnfen \epooad: Vthe keyuad Slauat ig |The ley! ward poten ze | Used 418 caFire a giauctuy used Uo clefine avniens Size When a vasieble fg when a vaniable ye asseciated with a Staue qgepatated with a -tuae the covnpiles [Dntion the com fles vailocates the merecay v/alleabes ; NX the mremeay | | Fog each membe ThE by oe ts a | es vs Y considening dhe [Size oP stoticluse tg est memeay so | P2ea4es thon Da equa}| St of Union %S to the sum vf stec €Qua) to the Size of 712 membeag.- OF Laagest membeg. Memoay Each merbea within a \mmemoay allocated B slachuse 42 assigned Shae by Tndividual Unigue sivaage aaea — lmemb, OF oni aie ston eae OP Union. value Altesing the wake oP a Alkeaing the value of Alkectiog rrembeq votll not ab feck fany pP “the membes Dthea meroang oP the |wrll Pies otheg Stouctuses- membes, valueg . Niece: membeng Hatt falta. |. bon P member, z paggacm bekween wnion § eePhn YUTob ; — |DrPResencea Fel ween rio “let's take an example to clemonataa te he cl#PRenenae Slourtuse | rdVidual member can be ameaged at a lime Revera) mmbeas oP a Alrpluae can tortialbe at once Blouct Pala f fnt_ as Hoan uge both ia and b sttnuttaneously cha b; Yala; Stauct hia ye yea= 370k y-b='¢'s 0k kle can any member, at any Hime get only one membaq an | be | acce gged al a time. only -Hhe -Pragd mentary of a unten can be | initialized: wnion Galo f } any of lican't Upe both | a and bb al once | chon bis | y Dato 7 | | Urfion Data 207 | a> 32H Ok { w.b= ‘C!s INO! this aPRectp the value of | eo. We an accegg only Dnt and stoucluzeg: =H Mroludle ¢gidie.h > UNM Tob a. Union choa rome (327; Pleat galaoy 3 Sak woakesnio; ° de . NZ and Haucluaez ee one Pld at a lime. Soucek Steuct Job = + | boa name (a9)7 Float saloay, ' | Fok wdskeanlo; ! %STob i | a rrafnt) | } Petint® (“size oP Unton=ded bytes", She oP (vob) )y paral? C\ngize oP stauckiae = Yo lates") Stze oF (sJob)) Setuan 0; y Quiput | Size oP urfon= 32. Se DP Staucture = yo. i Ce Pes rt a Swapping oP +0 numbea gs and | he value oP a vasiiable ing by Vakie || gain|cot by value = \ TA cat by Nae method the sialue gP--the actual | pooaretess 4s Copted dhe faemal pamamecteas-an_ || othe woade,we Gay thatthe Value of the vasteble 4% uged in the cal by Value method- GN _by » Pesenae Gm j-IA colt ey oefenence the ocideess oP -Ihe Vasfable t¢ paszed into the -finctfon call ag -+he actual pagametes. ste. value of the actual pasarmeteag can be modtlfed toy changing the Rorrel parameters efnoe He addoegs of +the actual pavameteng % Pegged. Ge | nll by valve Exorple + Sunppirg the values oP the i ent a=lo7 zt $F include cstdio-h> void Sup (int sint ); //pactoty fnt maint) wot b= 207 paint ( “Bofoge sungping the values lue oP aand b aq main Aze/ed ibeted| in rain: Wn" 1016) 7 4 i wna Mpainting +he val | i pe of the. function | | i | ampia ib)? _ pafinth ("APte sunpping yalucg fa rain aed so ed’, | ailod rll he wae oP actual pogometens do not chorge by. chorging he foorna) pasameteng in Call by nralue O10 bag ¥ : {| void swap (ft a int b> i iH fe temp * J qr i temp =a 4 : i| O=bs 7 | bs temps I ern ing values 0 Parelion as 3.0, b= 10 APtes swapping valteg @n main azi0,b=20 os Gh by gefenence Broreple: @wapping -the Values OF the lwo _uoo%ableg,. Aaclucte wid SHOP (int al) F/pavlolype oP the Panctfon | Ant rain 9 fab O=107 fot be 90; Paint f(y Belbae Sawopping An" arb) *Mpatinting -the Value of Sw0p (fa bb): a 5 Patni ("Aes swapping Ualues fa fain O= ed rbo= todo} arbi zhthe values of acho! posomebers do choge to i Cot by SePesence 10=10,b=20 | | jhe Volueg in trofn as od ibs 1od| a. ond b in mofn. ¥ Void Svap Ufa tRa sfAEEb? A” te temp; bemnp = tax Fa=*b; #b= temp; patntf (“APtes suapptg values in fianction = qed be4ed\n" a, ¥b) sl-fRamal bg posometens ,Q=20,b=/0 \ y Oubpuk= BePore Swapping the values tn main as Io; b=20 Pte, Suoapping values fn farction a=20,b=10 NPtea suoppig values th main a=30, belo.

You might also like