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

PIC chapter 2-Control Structure

The document discusses various programming concepts, particularly focusing on decision-making statements like 'if', 'else', and 'switch', as well as loop structures such as 'while', 'do while', and 'for' loops. It provides examples and syntax for each concept, explaining how they are used to control the flow of a program based on conditions. Additionally, it highlights the differences between loop types and their applications in programming.

Uploaded by

vrushalikabade36
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)
8 views

PIC chapter 2-Control Structure

The document discusses various programming concepts, particularly focusing on decision-making statements like 'if', 'else', and 'switch', as well as loop structures such as 'while', 'do while', and 'for' loops. It provides examples and syntax for each concept, explaining how they are used to control the flow of a program based on conditions. Additionally, it highlights the differences between loop types and their applications in programming.

Uploaded by

vrushalikabade36
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/ 30
Contto} ~ lof_Stalement's executor. I (> Contso)_ Statements ave - l I Contro) , Statement eee eee Detision Pking _ selection \ coping Sur ment Sheukeynerct = Stubgnents —_shaderr | Bashi | | ae oa Ir 7 i ile Goto ATE ase gtedemerh Adowhilé ; Bl esse 1f Joddee { S| fot 5) nested 9f ose @ Scanned with OKEN Scanner lwatte The deel sisn_met 8 - faites teat Te aie ng Se it 5 — chek different vw of - 7 [dependin which — PH ( ae by | @if_s e Tf else stadement ; | f ade a ae pe sere ree ——a laf _stakement “O Explain The statement With xa ple. [| ; af js.al_deelsion cooking sfecdemersh * 8485 _genezally used “hen we want to y Soneak J asia le (ondition - Ff statsifia woe will exeruke Some Code - 5 Synto - 5 if €conditiont ) Sstedement i 4 @ Scanned with OKEN Scanner | Fjnocha et: | write ! chan 4.00 of not- @ indude Bindade : Print C"[n entee a numbee> )) Seanfc" v.4'', &n)s ifCn Joo.) Print ]n numbee is Greate chem loo’) Juen¢y> ‘ | @ Scanned with OKEN Scanner 4 eee S Date NS BRN gee eee es a tne use of ifase Siatemend . lat else__Slalenent FS used Fo Jeu thew tohat 40 do to. both sityation Stemi orf n_(onditisn § fs sodtshy tang given Londition ty poy tated Spiee. TE Cond 4% L - =——_ - a | ase APP se SES re | § emi Pease eect @ Scanned with OKEN Scanner sv 7 (Start) : lst ZS a Noon ditio XZ tL yy Teint “Tokerent 1 | : 7] r ctor ST) di indude stdio-h Ff indude Lconjo-h Void main 0) $ St Number > Clrstr()} Printf(" entee the numbee")5 Sanf Clyd', Snurmber™)5 if (numbers 29-= =0) finn Nuraberr Ss even number”) i Use § Prins ( \|n numbee 1 odd number’ )) @ Scanned with OKEN Scanner @ Scanned with OKEN Scanner a as meth - way deuis Ton mi Exphin_ ese 8f \addee With evampie The ese if” laddee is used lo dest seref tonditiong ina Sequence. Th! USo_Considewed _ aking Gtauement equente With alumbet of conditisn awe give ons seb sequent Statements - oF an one Of the Jiven Condi rion awe Teatishied then they welared Steterm€nts ore execu Od A Confrolextts from the “se if ladder . : “hed _means Furthee Conditiong doeg mot going —t0 Cheaked - Babif wondihn not sahishy chen the compflee Taoing to next Conditisn UD Cheek cite nect | LY @ndition. Syntere TF Condition) : 4 Stedement leise TE ¢Conditilon2) 8 Stitement 2) 4 Pe | pt Condition) Stedement n3 a @ scanned with OKEN Scanner @ scanned with OKEN Scanner es : g al : issestansssssssiistl f stelement m See Ete ent : _ —> a iste Hew chaet : (steer) meh £ “TR Foe 2 — SHeeeement (8 ) Program Jocheek no fS Positive negutiye. arte we gatdiohyp Le tani a “void main) : 1S 7 int D3 i ~~ printf (Sin ente_a number"): [scant Cty.d "Ens ) a 7 aime ) inte |p no fs Positive’) % ae | ase if C n.do-) Ls % [ese Dy i g = C @ scanned with OKEN Scanner printf (In No is meqattve')* PrimfC \n wo Js ce#o")y % % Seth 095, — ae Nested §f ase stalement- 4. iPxplain nested jf else shakemenia + eee i > Wasting ff stetement fnside anothes Of o~ —— Koaotl_as nested $f etse stalemen, @ scanned with OKEN Scanner __.while_checking Number of tonditiens so. 7 feed cto net 9 stademeny Pngide ae + SL statement . - othe, | i SL © Sy nierrt . : - : TF Conditions) ! } : A ; te Conditiene) ned with OKEN Scanner @ scan — TEN Rus . A a Galena [s Tadenent J tetement 7 {2 ; L. . = * < (step) pe ey Se wosssetat Program Jo cheek to cheek _jergest © ale eee a et es —__ginade < state Aes [Sint naan2 7 | ae a —— I San: a — faa vf cni>n3) eee ee ia 3 print ein max nolsnl* yd ny ' : a : cs ae i— . print ec ’)n mat notsna yd in} [4 | 4 r I | arse if (ne >n3 ) 5 y Print€C “Tn mart is nu: y-d'n2)} I aye. ] PrINFEC IA mais na yvd 1 A3); f i 3 getehoo) 4. @ Scanned with OKEN Scanner Exelain Gaiteh_Stalement* 7 decision rnekin a) 20 ich_heeps 12% fo seed pe_given defies Sai _ceepressien \ Cayo tonsFank, OP rESSTOO § 3 fatement lL) break 2 “4 case _constent - expression? $ Staement 25 preal< 5 case Congant - expression n¢ Statement n), brek 3 defautt Statement + | Here Tvadiabie value ofcohith we want tochetk- expression itis gq Usually name of 9 4 @ Scanned with OKEN Scanner he “eas BB Von pFeS EEEeCeeeeaeaeeESEa eared ~ |These ore — p10 ie 18 OO i @ of expre qf Dheose se Fett IE value oF €*Po— ag ere syed Dhose 45 cajement $n CSE Sea = | The stalement — sip GAPre Padua _rmektnes OTT Geceea ———censtant — ~ Raaeeacal a ne of ——— ee ed aes pre sston rane is ee w sen tn elo 8 ee eee “Constant expressfon - ag OTH @ Scanned with OKEN Scanner Pa yord Maing) Vs eo C¢ Program to cheelk jiven ines: is a (on sonendt using Siniieh . apindude « stdiochy a qindude_ i ae “Chat oe _oasewt) + | wei Catpha } i print FC \n entet. auphaber "D3 scanFC™ yc", faspha) j |_ Swreh Caepha) 8 i Case ‘a’: Print C19 Vowel”) *, break $ (id. Wasnt er print fC In Vowe)") ' breowk 5 ae | clase 1 PrintfC " [nvewel")) breotk case tol: Print? ¢"|n vowe)"); ae Case tu! beck | Printh@invewe)s break * defouit! A @ Scanned with OKEN Scanner Po —— | _ 2 ae —< jatement ate wed to execute Spelt pssh 9 zepeatedly ~Tphout Progam : TT U 7 a fran wei ting Slakement again ond oggi, conceprS 7 of }ooP -' eh Se, \ we use “There Gre ‘Tiree types of loop | sO, Loo P | bile loop bile Joop: &Uoop, @ Scanned with OKEN Scanner Ex pla piShile coop sith Synlon 4 example a jo ered = Gnile loop ts used when we _ went Jo exe e othe set sf cyadements repeatedly un | the given Condition 1) sabistying vs — 7 phile loo pis aso Knmwn as entry con bo] — | __ loop { ; i - ~ | That means the tondition 38 given at the eginn | ne [ef looP: : “El given condition dees_net sutksky +thevooP | sralement nevet get executed «| ~ tf condition 1S sahshied then Joop S Federmén Tore vepettedly eyewked until conditen 15 | Sodistying , Tone Contes! Condition besornes qalse the onto] exist the Joo P’ Syntoct | while Ctonditlen 1) SFetemert 1} 4 “finotha e+ — | | Sar Aohi | rue. —__| Conditions } (op arene] — ch CSP) srafeme' [sae @ Scanned with OKEN Scanner Ca wee lorlie. a proytem_esin ee “qindude cstdio-b? ____ @inaude joo _____ |vofa_maine A @ Scanned with OKEN Scanner ‘9 povite o proqrom techeck The no 15 Prien qinaude Noid main ©) i. ink ni ie 5 ‘ a ies =00= 4 | ov nod 4-08 : vi me Flag ts en Vention Veattabie Which here fochek whe thes no. — Prine ("fn entee anumbeg), 1S Prime ev not Sane Cyd", §n) 5 Sate (id= nj/2) Weve fnitiauy i+iy I 4 sek to 0-- Feta vis =o) | ~ Uni] wanue of f § | Foy = 13 bewmes hut of the 7 ; breaks Tumbet he Joop stelemer i Wii be repeated - if Chek H A iby _)uskethert of ( F fiay= = 0+) jie Vprtnse C9 no [Prine yee ¢ eLye egy printf€cln no hy Not prime 2» weal ae “he — pu piRe r pamyenit ge jet : @ Scanned with OKEN Scanner — “2 po_whil€ “voor. EEE ae = The _dowhile loop is extt nfo) Joop> “Inst is The Cheeked ot end of He - Uco p - ‘ = Hence even SP she condiHon does no — Satisfy. The loop Sfatements iN be | execuked at east one. : =) Syntoxt |. i aI do \ Stalement Ls LY hile Ccndi Hem 1): ~Kladae) Cone J T | t s ements { [ SHEE hie Vue YH ‘ Dia ab Grp) 7 eee @ Scanned with OKEN Scanner 24 torte og Using “do while Joop | aqinctude ¢stdid-h> | Atnejude : A incude ‘ : oid main) Jat no, 1, sum 26 | conf UV v.d", @no)s Ace (T=) Tee 03 144) fer _feintf(“Tq_plew se entee _any’numbee’) * Same Sum th3 g | prin C" Sum of numbees%d" Sam)' 4 | etch), | write o Programm do Print the d4o25 no's ee Using Los Joop. \ @ Scanned with OKEN Scanner . - @Pindude Gatdiohd. Include J conioh Void maine) t — Inti —clyscey (9 5 % getth () 3 ~ PeintfC'In xd" 3) @ scanned with OKEN Scanner choo difference Woop a Sa} € Any _ oR ee =e) | belscen vahiedaop 4 Loh le to oR @. Ske ony foe difference behocen while loop? do a write the diflesence 13 also expla ft ins Syntax of ie bepoeen woht ned do Obt, Je-JdooP “ Pitomele €. \white doo? + De whe doop~ 4__Knaona$ This a This |naanas I os enky + “ exit combotied | (omfpolied oop - doop. 2 fashion of Condtrien is ase Corditton 75 Conditon: at besy inning vf dhe Qiven ad cloo'p . : endofthe ' Uoop © 2% Biecubion of \oop stetement Leop stakrer — oop stedement - never exembe tf execute Onves_ (onditton does not jf Condition Satisfy does not —— ae seutisfy Sy endl ——— —_ a ae — Cte ee | tekenrreng 5 - li ition @ Scanned with OKEN Scanner i 2h ——<$—< a 4 corte. the use of F Continue Staiemend..sdith ___exampie 4m | . Etre ‘Continue statements ps mostly used }nside iL Cheloor: wohene ve € ibis entoun’d inside a looP Contro]- directly Jump to begnirg of the looP -loy, next (terabion . lf |__ Skipping the executen of Statements ar = —— Inside ~ {oops body for earvent jperchin — |sgntaxt fore Cinititizadienj conditions TAcrement | | 1 deevement) 4 Statement 1 if onal tion 2) : continues z jadement 2) Stuements : @ Scanned with OKEN Scanner 27 Texameie if @ fnaude Letdiob W fndude {eonto-h> cea votd mafnc) felt 5 : int 1 fox Chet's ide loy itt) a if cis =s) | continu ts Printe Cyd" 1s a u % ie | jéteh c) | ¥ : 9 | mescibe theuse Of break Statement - The break Statement used te exit 5 From the 1vop sor a pwaticulté condition break Statement} (en be used +h Soikenf ~ t joo PS —_| Syn tar. —! for (Initiqizations tonditeod 5 Wi — 2 > rrr Peeves] Stelementls eee @ Scanned with OKEN Scanner 28 TF tcondiHone) _ breck) Stetkement 25 4 i : Stedement 35 cam ple - Gtnaude Vold mafnQ § Int]: ITSCT LY e lor C1eV side srt) x | \¥cis=5) break > = print fc'ly.d'' i} { gereh 673 : @ Scanned with OKEN Scanner 24 aq. State use of gots Shecte ment [Goto Skuements ave ased +o transfee the contra) te lebel specifted with the gots stectement - -| A \abu isang name given too Paettculat ~~ T Pastof a Program. T L I Jabell Thus TECON Shows the jabel Con be beforeor at tes the goto statement €hence the contra [ean ustng chonsferd fo earigee or next | Stele ment using Goto Steckemme a - example - Ginetude

You might also like