0% found this document useful (0 votes)
50 views

Lab 2

Muji

Uploaded by

vipar snike
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
50 views

Lab 2

Muji

Uploaded by

vipar snike
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 21
4d) 2) 4) b) Ge Chograrnning engage (hab -2) 4+ Teor. Cheratiors:- Qporators perform wore. operatiore onthe. operands: {fy caarmple + int Oe de, fg ; bao: ce a+b} dzaby e@=axb) f= %b; Hote, the operddou'+ 'denotes adtition operation an two variable ‘a! and ‘b's Tn this content’ these variables che donown 4 oper ancl Aimilaly, -..° —' denotes subtraction, x! denote mublipticalion and ‘7 denotes division opezations rapocti vety. Lappession: Operated and operand are combined topelher fo fxm onenpresion, hha onpseasion hos c4stain volue ns gr RUE — 15 #X/5 +20 Isom enpreasion 4 225 the volue of this cxdmble expression t4 430° Z | Spesof_0panalors Actthnolic. Opetaters “These perados on4 used to feefotmn orth netic opttations 07 the operands. + Unaty plaa(t), Undag minus(-), addition +), aublrachon(-), multiplication (3, division (/), (Module division). lonol. ote athe aelallored operators ate used to Compare arithmetic, logical and character, enpresaiony. Example + Is Lay than (< ) , tess than 04 equal to (£5), Is pecatte than (>), greater than of equal to(> =) ¢& equal (=) ,not equal to (J =)» AA Logical opetatow i¢ usd ty compote of Cvaludte Logical and relsbionol oaprestion. Logical pnp WL), dyicod OR (M1) Bnd Tit nor (1), 4)|ichomenf_and dectoment operates + forte and predic forms OMe present He 09 :- Li 5, che p Ha 6 phe -Inaement J a+ SE breguivalent to aeara Att IS post —indement ga. go beans t acare Bat bettas hos the eet 00 follows: aeartd bea. hed tb, 0., is fisat increase by 4 amd the terll & atigned to b- usaptes betta 51S executed the vue 4 a ard 5 are a=6 and b=6. Simi feuly, batts Ay the fet 0 follaue: bea Oéat+4 hat tn, first ais assigned tob» And then a inctements by 4 Phas apler beatt) js Cuecuted the value Ya kb ate: a=¢6 bee &)| Conditional Desalt - The conditional operator comists of two symbols question rakk(?) and colo (*)+ Jt tale thtee operands wo it 2 tevmaly Cpetadot + #)} iste opaale'- A bitwice opctate. operates ameach bit “af date. “brample: Biwi AND), Bhwise ORL), Bitwise Oxchaiee oR (mJ SEE Bf) 1 Shift ple (>>) , ony complement) 3 ; Ss ype coating in Cis “the pracou of cOnvetting « Value from one dada 4p omothey « Thole ote “Luo yper & tybe costing Inc. fort ng ( Automattic. pe_Con vets t on): he tye of cating a popored by de compile, auto malically, when if enceunkou ited dala tes in enptetion. Snpbicié type cealing, teu whim & v abe of ome. lady 44 outoalically converte ty another dato 44m wlth ad basing 4b precsion 0% Sata infrum int = tor float num. float ; Hum_flod = Num—ink © I Pty Mk casting» ind Tn Hhe ebove ssamle ie Inge ee is oe b Q Floating - point value. "4 Oo” vomohy ‘ pet Coatin (Monuat vessiori Ki type of casting 4 ed eaplicilly by he Preyramnets Howler plecig Be dae befete He _ te ees) Ape in porontheres ofote flowg Num - Flot = 410-9; int num. int ¢ eS Numing = Cnt) num -Float + | | Eypticéd cob) eet bo inf Jn the ofcove ecample , the floating point velue "Id. 9! j'¢ opbritl Coated to am Inte tewtling in ‘Lol, . aplitl type Be oe tk i 1 Me sede dads con's holf the entite value of the source if te shold be Chereled “when Petfosniry wry y dey of Pleclion % “Unt rphndty behav tog byte canting Bb pretbrt tn dhe Prosar. ING Lype promotion dy the Implicit Conwetsiyn % Gorm Ly a comm ny type duuing fhetry op, fomelion calls b Orutd COnnpeLibilddy ofa Operations « Troyer, Promotion makes gymatet UYppta Int sited anf Ip eprosiOns , operanda of Afferent thes le converted basedo, a Kicerely of “yfer. tena Hine de vold naln() int RF 40) b= 50, %,4 5 Lette x t4a — ttay gate, % bey - bea; Print ("Value aad and Value og LE hd" a,x). POE 5 Value of bay etd" a, qn, Mond Weg = 1d 04); ? Output Value 4 a= 413 and Value of % = 156 Value op. b= 43 amd Value Y Y= 140 1 rin = 3/60 esidut see = e760 D's min ond Jsldy ed se. Figs Flowchart fr Q-No- 5: Po GuiadionNo= bt WAP to Inpub seconds anf Convert to rninute Ajgstthin Step J donde Hep 2s Rood eteconds on woe BH 3? Catufeld min = Sec /60 MEY: Colette 4Widual see = Seek 6 atepa: Sisploy Min ard swydual decs okps; Stop. Source Code Hinchede <5 joshy # Include Zeonto-hy void maine) int min, see, Lesidvel. sec » Pritt "Enter yo number of atecordy: "J; Lonfpy " besec)» mmin = sec/éo » YeIidual_soe = see 1-60; PUL" hd seconds =. minutes ard 1d seconds ", sec, min, Ae sidudl sec); , etal); Enter the number. y secon: too 400 Seconds = 44 minvies and 4o seconds, Displagg Reg senses ‘and keg - Parallel Fit. Flowchart 4 g-Mo.€ 2 =¢. WAP to compute equivalent heAlstemce t {v0 nth is 1004 Ri amd Ro yy ham they are connect hin 0%dt, and por allaf Connection. Algerithr. Step 5: Start Step 2: Read the value Y Mdislances to, nesiaters on Ry and Ry: wep 32 Caleutate Cqulvalent Keslstemce in weries Reqv. serion =RiERy HE YS Oot culate Cqubvalewt sestctance, in Potable} Rea. parael = (es Ra) Hey + ®) apo: ‘Dis play Reay_seriea and Requ—-porallep « BEDE: Stop: Loutce code FH include F include void ratn() Sat M1, %, Yseries, Yporallef 3 printf (" Entes Begistance 9 Ast sesister ="). sont "AP", By): Print" Entes seatatence Y 2d desistor = "); Scant ("f", & vo); CSeY = XE vO $ ¥ parallel = (wi ¥ ¥2)/si + ¥0) 5 Print? ("Tie couivadent resistance \) Th sestes = ENT Patollel = Y.f "" wsetion , Sparablet ) ; () ) feed a, bi dy arlOrD 35 Lb hte Jz(2ep) +g) Fig Flacbunt of g.n9-D- Qutput Entre Redidtance 4 1St reaiates = Enter résiatence 2nd sesintee = Te cquivolent resistance Tn series = 44, 000000 tn Parallel = 3.94 4096 Question-No.2+ WAP 4» evaluile te enpreaion : V= (ery & PY aly yes Algoiéd hin. Sipd Sturt S#h2: Read the values gH 2b, Pai % gy SIPS! Calealaty Y= (ery Jats Worry) (agp? Sep 1: Neplay v Sith 5 Stop. Source code F# include oF include < conto h> Hinclude < math A> void mabn() : float Vy arb) P42 Xd 5 printf (" Enter the values of @, bi pigs y in the some oder, efor ade by comma ="); seo (Dob Nh 1h, TF MA tht", a, Wb, YP, 8g, bn, By); VE powlaty, (a4arb)/P 0) + pow Ceuy), e5)5 Paint (" Votve op = cht", VI; Fetcncy, 9 Figi- Flouchent ofp Q-Mo—~2 — Jo a —— als Eniee the values of a4, p, commag = 49059, uy 556 Value g V= 6049649 Question NoeE. WAP ty Oh values of Uho0 vahlabley 4 Bf Aethn Steps? otlort oth 2: Road the Volues of amc y. wtp 3: Declare, ‘tompotaty vaslable Lemp. bth At Put ‘temp =. mey = temp, asthe Vole. Of % bey offer Sup ping Source Code include H#lnclode I Tn # include void main () chok ch ='h?, printf ("\n Coup 4 the" ob)s priolf("\n Case 9 ; /8c " ch): brine? ("\n cose gs Arbo) ch): guencys ou j Qutput Cue 1: b (ase 2% b (me 35 4 db Hinclude # include Void main () char sdx[oJ= "My Nome is Amox."): brink ("\y Coued t n8", sty); Print (""\n Case 9s 39 s!', stv); Print ("\n Cage 9: 298", 542); Print ("\y Cose 4: 9988", st); Print#(" \m Caae 6: 1-199" 540) PIE \n Case 6: Yeas", sth Prints ("\ncasga: % 98" $9; Al) ) We Seger gt we My Nome is Amay, iz My Nome is Amy, et My Name is Amay, ne M en ty Nam 4 Nome ast My Name is Ama. we! My Name 1 be #inclvde 4 include void mainc) char strl5o); print? ("Enter a stings" sont ("7 Soc", sex). “ ; printf ("" Reog sting Is: getchc); i Out Enier a stings Hello T am Nisa Regmi Read stung is: Hello Tam 5" sty rst) . 46 Faivelde (Sulah> llemae ge f Hnchde Heoncept sete sett “eed ating #include void main) chet sly [a0] Prine ("En boy alAlng » "), scomf ["¥7, a-20-9)", six); Print (" Reog sing is sefern st). guru; — i Dutt Comment. = " sue) , ; Leon ("/-Ta-20- 4) ates i Enter strings nirjasenSundeg Te wend He ches eae 7 Rood sting ist nlroj26ay CN Countess Chase ° than a-Z and 0-9. 3° +#include cstdio., H include ccon to. > II concepe Of Seatch Set ty toc Sting > Void rants f Chet, se[20]; print ("Eien Sxirg: ") seamf ("L T°N]" ste): print (" Reed st2ing ig. 1 gett); 5 i , ste) carts tb Enkes Seeing: HeMoNdovid Read wring ist Hedly Comment. SP" ATON]"6t1); tb seeads chotactoes inte the whe onrag until iL encountets the choracter 'N!, )iscus.sien Fhe Wah exercises in C proguamming provided Invaluable ineights Into fondamentot Le oe G9 increment operators, ith rnetic. operations, foxmot specifiers p and inp ut /o utp ot fonction Tsugh ante on cxploralitn, ttudonds gaired prrockicng Pepevence in catlting code ty execute epedfic tusks , featerane a cheofes ondesatarcting f Ptogeommlag Punuples Gy Sunning any anoly ing Hhe outpt & ty , ahidents QePbed The importance d TR propa Hoppe p Of BLUE format apecifios wage cy] tyne biedsi0n for accur dle dota ation. He. eneteise ale elbivaled c2/Eenll Hhising an? Problem —

You might also like