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

C Control Statements

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

C Control Statements

Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 30
Pe Sahl. statements ¢ i Are wl tyre of onhol alates, p branching Cor) condifonal Stade meus 2 Looping Statements. 4 cond?fonal The Statements, + Condfonal starements, fare! 5 use +0 Petey, Some operafon bated om lke condition . “There are #ive types ot condtonadl eed 2. Comer, t lar, et a / , ay TP ~etgo j , Wad ae ee Pelco _¢p. lor) selee % badder. B Nested t# I CO Bt 5 Hye t brat @ te. , my er ® riers ThE JF —Setememt feused tp etx conclig ; d ion andl Perform Some eperartfong depad —"4 eup ou rhe Conectnese Of tue Semen of ye MAGNETS yo Condon £ Ccondtifon) Lt Sp , Flow Unart 2!) Scanned with CamScanner GP tre Common AS PUC Hef block fe exfetute, e sine cond?on %S Falee 92 ok come out & ture ‘blocw le WAP for Hotate meet. - at fnclude » odo. h> main i . Int Marks 5 Pata $C% enter your mouks”) } seant (“yas & moytS) ' SE CmarkS>= BS) 1 PA FO pass")! WR Cmarks 235) pital FC tof")! WAP to check Whetner a percon FF elifole to vote oY net using 4£ statement | at Include LStdio.h> matn Cy Pry age; ‘ Pitat £ Center your age’ "yy Scant Cuca page) Tt cage » = 18) PRMEL C elafaple to vol), e Cage Aly) APrtnt £ (“wot elgfabieto vote”) ! Scanned with CamScanner 4 ! e *e { Bt tne condfiton’ fs tm poe ING, wi, eiculed . Tf We condtivon Uk be — exculed E ee N ®© %F-elge cater Foca | | syntat + RE Ceondfon) 1 \ ’ gp WAP Hor TH elce statement’ ; ae Include Zstdio.h> 5) ; motnc ) J nt mavk s+ Bet . Pritt FC der your mares)? J Scanned with CamScanner sean (md, beares)s ‘ ‘ Sa Cmorks>=35) Y sf eis? Crack " else’ Pao # Ceti")! Ow #P +o ehece Jalhebver - Ht fnclude 2 Stdio.h> Lis mata C ) J nk age . pint £ ‘enter youn age Hy 1 Fant Cyay § age): 8h Cage se is) J £ PAL Celafele to vote >; 2 else - , | _ C otielgfoie tovotd) | ; on (WA pot uneek ve der) - ) ® fe-elce-% cox) elce—9¢ ladder Staten sus wy TC cond? tion) (sib RR \obaloet 3 . ' else 2 Cond?sfon) Bike». else%? C coudifon) £ ate Yevoiys on om geil Scanned with CamScanner Pow cherie else th body 2 ) : : eee fe adder an enantio of ff else ate, MEME. F-the — condtator 9g tue Of blow wht be -efeuted ~7h the condifon fe false One of the. eco Sf wri be eticrted, Flow chart : ® write a prgramme -fo check Whetrer two -Auimbel He wo be aloosided | ay goadech). else ne hn awarded as il’ At Include 4 Stdio-h> Mork & emowkcs p= . main ) Bh cosas

= 40) Lecmarksea0)) |’ i Pinte Cay") k > ; Scanned with CamScanner f wing (“et”); ‘ vine ee ° . ase marks x) A sts 15 2 cise FF Ccmarks = so e4 C : j , | | Pint (foi |) 3 i mv) y 3 Nested 42 Tn a * Condon FH, cine * alte ed % condAvon -wen we called AS nec ax! 8% Ccond +) ) widur one? grated ustry nested At Toelude ectd?o. hy, mofnc )* a £ fot vor) vor 2 5 Soh 2 \ Prat Center vari ,vare vas) 32.005 * » Scant (%ed %od, dvorl 1 4vara)! 44 (word [evara). wn! Saran): Wag £ Print? vari |= var 2”); ' Scanned with CamScanner Vt Cvatt > vara) i Prim! vor & greater”) } elce ‘ Pratt Crore % great en”) 5 Bas e £ PARC von d= var”)! 3 3 Get stetamend: @ WAP wheter a person K&S elffiole to Marry OO nor for male we age >= 25 to many anol fo¥ -Pemole teaqe should be >=Ql to mary. ab Ince £Stdio-h> maine ) 5 ‘ thay ch } int age; . ; Print? Center your gender D5 | | Scank (* 90", gch) 4 Cch ez ‘m) £ Paint? Center your aye")5 Seant Cd", aye), 48 (age >= 25) £ PRC teefbte to marttaye”) 4 Age pire “not eligible tp marrage); Y Scanned with CamScanner S$ Cch= = 4) t eat . 7). Meee paint F (emer your age ); oid : scant Cyd", dage); % Coge >= 21) Print Cet%yfole 40 martage)5 else oe ")r Pint (not etfjfble mariage 7; susith statement = , sutton gace Gade Fe used por mull ple” RerPoe options and we need +0 perform othferent +asle foy | d’Sfereat option. syntats switch Cvaviable » or, expression) CASE Constant { Care break 5 Con case Constant | break 5° default + break 5 Scanned with CamScanner rose a) euerute 4 25) OAS 2 Will, be etecute. Zicr. statement @WA Paludaror programe using’ se =e Include 4 std¥o. h7 matin ¢, ) Oo Aumi , NUM, yesult 5 char Ch 5 he pint Center numd, numa values”); scant 4, ded”, dnumt, numa); print (verter your option c4,—1 #. 1)')S SCPC. Yc, Bth)y cwRith (cr) i hy ? case f+ result =numd numa: pitt #Cvecult ="%d” result) break 3 case ‘_'+ en yesult = numi-~numa; Pitnt# C“vecwt =%d", vesult)s —_— break ; Scanned with CamScanner PO —__ —o“=— Case “x ‘result = numix numa; Prt yecult red “reult); break; casey’ + recwt+ = Num d/ num2 } Printt (“result =%d"), mee: breaks default + Printt O° Rnvalfd key”): break ; 7 y ve Pe Pp to read weak day sumber pint voee day name. ‘hy anit =H Pnclude. caidto. h> moinc ) | : L pany a nt w days ; piint# Center wdays 25 seanf("y%a”, Swaays): _ Cwdays)- Case 4 Prin FC" Mon”), | break; case a: Print! Cues”); break; case 3% print? C“ wean” Scanned with CamScanner break 5 case ut print? C° THRIRS") | break: Case 5! ; pitat # CART "D3 preak 5 case 6% : rd paint e C'saT?)s ‘ break} case + 2 . | print? C’gun” 95 S P | break; - | default z my Pint? C'anvatid w days”): : . | } break} vo OWA P +0 PRA vowel cory NOTH UAriy srs. ked Statemeut - At nude 4 Std %>.h> maine > ie id weg § St sire vob ef | chay ch ; ( ynPeat Poe Center any cha'racters”) . q Scant Cel, beh); SwrtCh Ch) i case’o! s case‘a’ + . Printhc" vowel ")3 break;,., , x oa | Scanned with CamScanner CC _—_—_ <= £@& = = ——e Cage \e!+ Case e+ Print+# C vowel”) ; break 3 case ‘f+ Case’: Print? C Vowel”) break 3 Cage ‘y's case’o’: printeCcowel %e break | case ‘y's case‘! + ' Pri? Cvowet”)s break: defautt 4 PHA C Conconant”) ! breaks, @ wH Pe topknr yoo gevler Pin se fnutude 2 Stdio. h > main ) bo ¢ be, char ch $ print (enter your gender ”) 7 seant(% 40", Bch); switch Cch) case \p’* case y nh 3 bru. 1 Brevarive |_tyoping statement Bn Looping a pregrem sgram . execittec ~neagequente ot clatements many type times wut? nine condition Fe Lalee Joop conc of two Parts, i r a, Body of me Loop 2> Cont! Statement Dre contrl statement Fea comnatn Come cond? Ans that dfrects tre body of te Loop +5 - etenites wtf) cre, condiion Ye false . “there, ave two cypes of ops ; ‘ 4 pretest cor) emtry tontapled fioen % posttest cor) exfe contnted Loop dy pretest ¢ Here she condition Sit reek eter soe atier %} wit! eater Xnto tre Loop. TP te conolitfon te ae will enter frto tae oop . ot tee Condon 9s Baler % wi come out of “ne oop S Posttest Th enor Comtipltect Loop once the Gnd) OM Got Stakemende uh enenites hen after Aw Cheek tre condhifon 9 the Condlitfon fs tue oo me PUT Ve neaten 8 me roncliton fs -falce the | Scanned with CamScanner , ( ———S_—S-tll—le_ NE so tue Jpop te exeuited - oY Bounces ¢ were tne programmer KNOWBS ED e44, how many mes tne pope Tepes le fz=to Heke ame Loop yepeat? 10 oes does 10 rong Unbourded ¢ siere the pagrernnt fe ik Known & how many dimes We Loop Pore unbounded - 1 46 Fs 20 2 2, ; Here the Loop Tepeats Infentie mes, “Wee ancl’ fort are tthe! ipresees ab vahitey fc a posttest’. > We stph ing 9 r “There are three types ‘of doopng sBlemed ts, Ad. wHrlec 9 toop » for Cy Aoop ' , “do. uanfiee 5 ‘Loop"” mo aay id why a. wWitlec ) Joop Rea straight trward bop Conefottag oe! Tia Paadion, condition ot peng “An “aires dtéfevent nel . j f a ata ieee: lPnes: a } Whe Cebhatifon) mM pes yt * updarng 5 Scanned with CamScanner Flow Chart ° “antisa Irzarhon Cana ae OW 6 P 40 pat ~the numbers from \tojo. =e fnUude 4Stdio. h> main ¢ ) of Yt Pets while Cf 4=10) priate (alo 795 Pos Bas 3 t, 9 ® war to pwrt woe numbers in weverse order using Whe. wil. Yn eee ste Anclude “etal. h> Mata ¢ ) L Wy Ink), Pe tos wantee? >= " rt ‘ path al’ ds Per fe 3 Scanned with CamScanner a Sng dove o ® wap +o pint Po loving : RHE Kea LL loom + a | we Vin ote Prelude zsidfo. h> yee f maine ) £ bem Fat Pots { 4 wihflecf2=t00) | Y | printec®. ae ”, : no Ths “— i 4 A oTWHGA be f= @ wn ere acter adavle on tom (4010 uftug while - Ae Mclude 4ctdfo . h> moin ¢ ) } fat Pa1 = while (Fz = to) mine Cae as aah Tawi); 2. ° iy ko tht Dk2 xy Th J stor? > Loop # Snfralfaation , condition and u yin fn a Sage fine. 99 Yor’ steriement by _sepaittg fbn sem? colon C3) ¥ “all + Inf: Dr PS apyerest Soop + P pee? SyNtat + ¢ for (ntatization ; condérfony updating) , b. Scanned with CamScanner © wap pint [1010 Numbers Uting For ‘boop. HE include 2 Stdfo - h> mainc > £ Sint Ps ForCisds fas TH+) patty, ath, 39.9 a ® WAP vo print reverse num bers HETnclude <64+d7%0.h> -main Cy $ i Gert 85 fm 10-0) ustng for loop. 1 Movesorig tetas $xeh iy & 7), wheel fhsdo i pce PRUE Cd 8s oon , Kiang ad : , 1 / ; @®D iWin’ pe jto PRat toowm sross. Ulty for oog i BeTnclude 2 g4dfo.h> Print? Coed 3 } Pe Scanned with CamScanner Fe wap wp rhs wrale MEO Fmm \ t010 ' ae se fncude <8dPo. h? matin( ) % printf Clown datdh» 7, wx?) 3 ; f 3 . a Ge maitlee tose do — wWhitec ) Loop é " , whic and —do-wifle Lsop ave simflar sexcept while % a pretest (oop , condivon Will check Firstly - siren afier Suki ester/“frty doe toop . where as do—wlfle % the posttest ones the condlition wen encort Then after Be uSil check, tre condi? onele condtifor Rs te’ Pr WN epeac tne Beep conftfon Se false wil ext+ Bom'swe loop. cahtie the condigon ended: white usenZ colon. fin do | syrtat ———— do , i white (cond $4400, Scanned with CamScanner ~ Flow Chart 2 do—wlhe do volte too: A O WAP Yo Pant tow usmy do-while- AEPnclude LStdid hr matin C ) { Yat feds do? . L ‘ Printt Cydin”, 9) Pat 5 Jwlte Ch=10)5 2 ® wap to pit staple 4mm el to 100 numbers « Ht fautude »AStdTo. > Mafne ) £ fot F218 do ia i OF. 3==0) Print? Ny Wen, ; qa hd) V5 Scanned with CamScanner 3 wwhtie ers =100)5 | 3 @ war voprat wrare mite foltowing Lang| using do-tolifle . | HE clude 4 Sto. h> Mohn ) { | Tot P= 3 do PPLE Coxthd © hdin’, f, tomt)S We } vokfie Cfe=to); $ ’ D WAP — snane combinarfon of cuftch ©) and dort # Tnelude ectdio.h> | main ) bo bd | 3 ae fat opifon 5 char ch 3 do ‘prinig(%4 Hel, 2, welcome ,| a Buea ")s LANE *+1.4", Boplonys E atten Coptfon) £ case 4 6 phate Cueto”), ba break + Scanned with CamScanner 4 Case at Pint C welcome’) 5 break 5 cose 3 ' pial? (Saye) 5 rear 5 default + Prt C Savalfd key”) 5 break 3 prin CS yaomt $0 gontfnue yl”); seantic® 9.0", bd: Joule cow 2 = yt } Nested Loop # Dn a op Pe there Fo mother Loo} Nettedl Loop pie: are Biypes of Nested tooP “atte ¢) Loop 2% for ¢ ) Loop % do-whilec) top p thy, We called as Nested wWhilet )Loop # Gn a wlte oop 2F nerve H anodner woutle toop sen we Called ac Nected whfle Loop. Syntat! wile ccond 9) condy © Sratemend > white Ccond 2) i ca 2 Slalemed + Scanned with CamScanner ~O wap. +o pit fntwe folloutng —formert Se fnunde 2 Stdfo. hy maine 9 ! : L tnt Pa os Witte’ cee bey i Sais) wusle Cj2=%) printhead", $y, Sot; nol bing G ns Pes 3 | 4 nested forextoop & In a for loop % tneve Fs another Py Loop tren we Called as vested for loop. bn Scanned with CamScanner a Way ee orc cond 1) i condd Stal Omen “fore cond) i Sat 2 5 3 Flow Chart 2 Pow Sang ° ° j ested, 5 ' OnNAP @ PIE uaPag dor Loop ~0 pant th tne follo Rag format * * wR ae Pnctu de z std?o.h > me 2 Je ee maiinc ) 4 Wnt 4, 5 Matern: ‘ j SWHey PHnte In”) b>? mec 05 Scanned with CamScanner ie WA mudfiptrtatton fable. tufug MUNN” for fog, © ( 2 Rug AeTUude 464470 sh? 2 4 6 Big mane ) SZ 6 4 12 te 48 12 lear 3 Cy lO 1€ 20 as nt Pfs NS fore Feats T2253 f+) £ fos Chats fa=55 fae) i ' PAO cng aa, fx3); . fe > | PREC (NDS | x yes oS \ J nl oe | 3 l= (e Nested do-whfle-e 1 Leop & Th a do—whtte Loop PP. dmere Go tothe do -WhPle | Loop then we called as" Wetted do-whifle’ +7 er i Syntans 1 do r wae | i do £ 3 wile ccond 9) + J white Ccondn); 4 4 WA P 1 PRR Fy the Pollowseg Uing nested do -while Loop," 0000 = 2 o 7 wpe sere Scanned with CamScanner Gncluce £4 dip-h> main ) i Tor hoofs do i tae Jol do Bboy PHO Cd techy 7,595 Sat 5 3 wwe fa=u) 5 pS On" tts \ pwrectn2)5 ‘ iis 1 kK uncondiivonal statentenice- aid swerve are ‘3 typeS of unconclitonal —statemenss in see. Ava 4d. ‘Breaks 2. continue 3° 3 goto, : psa, (0 4. break 2 Fr Ge used to 4ermBnet -the Execeut%on of Joop eincondiWonattly udkrg break, Cratement . % uced as Exlt from ste Loop - break can be used % while, do-iwhfie and Ay oop s * “eevee Incase of faner Lvop ey byeak Pp -ferminefs the wop of Srey ony . ‘ | Scanned with CamScanner Ownwnp Luhy beak have mtu ae Anuude 4 stdfo-h 7 main ( > Fort Fs for Ci festo5 M4) L 7 PRA CY, NTIS #209 = =|9) break : 3 y : Continue £ Se% used 10 skp Ae Slavemencts and Conte wine neve -PHeration . contfrue % also Wed an wikie, Poy ad do-whidle Joop DO wap to peat sum of ne number, udig cone fe statement. “3b %clude 2Stdfo.h> maine > sum = Sum4nur 4 4).8um)=0#to slo Tea T, nue , sum=o%, 9, Sum = loH20 = 20 for (fel, Mees; tHe) 8,.8Um a04gb £60 4s Sums Gost = (00 PRO Center any number’);| © SUM = foots = scant (+3 ") gnum); ¥P chum 207 i fh ” PREC negatwey: conifnue ; Sum = Um+ num 3 3 ; Prt eC su 3”, sum); Scanned with CamScanner , ees # goto Statement Ye Used to Jump From one. ped fhe ro the tmetney line Yn a prgTAM. . VEY 040 HalemeutS musl avd should have lable. “we label name ghoutd be ended wita semécolon, forward : oe goto habel, back ward 1. ae =——_ ~ . Se dabel 5 \; -~ oy van got tabel ; © w AP uctyg yoro Statement - ae Include a Sto .h> mofnc ) £ Prt num= 3 Yepeat ! print C% din” num): mUM+4 5 PP Cnum c= 10) qoro ae 5 wale 40 phuct Pn “tue fottorchog donuat wy fretude me KR 5 t. 375 ee ae ar co Scanned with CamScanner Fo PREC IS of q Print-p oO In"); 3 3 WA Po pit — Fn the rr By 12 3 Cu \ folto rg formas AePnctude 2etdo.h > mofn( > wap to par Trane followy format a 3 1 oF wer a4 g 410 ch ° | ae fnclude cctdfo .h > main > L at ?, Senumberet tor Ctet; PoE } TH be Ok Scanned with CamScanner For (§atsy feats Fei! UW Lo PARE Cy") number? 3 Mumbey ++ 5 priate OF "5g 3 ; ¥ 2 4. 10 Ae We P to pind in dine PodtoutPre, toma Fae eGnclude | ZL vain CD ‘ 1 Leiba fat ?, 7), number=i03 Be Cees (PoE ween 3 for Seb yice?: Say), i A PAN (“bad number) § Number j- — 5 prath On) 5 3 $ Scanned with CamScanner

You might also like