[go: up one dir, main page]

0% found this document useful (0 votes)
31 views18 pages

Loop Questions

best loop question in c for exam

Uploaded by

Sk Samim Ali
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)
31 views18 pages

Loop Questions

best loop question in c for exam

Uploaded by

Sk Samim Ali
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/ 18
Loop —— Blwrie a @ progrovm te ind oll ty2 rine vo, yo 42 1. Avs’, & tnelude stdi0-h> ink check prive (int re n un) ‘© Crum <2) { yequrn 0; J ewe } @ int xsnum/, for (int Pe25 16 ¥7 ite) { if (num % i =s0) vefurn 07 } } } veturn L 5 j ine moun () for (intheas Peebs Teh Te(checke prime (1) Printf C4 Yod "7D 3 5 vedury dj J G2. write a complete C program to Fre vate Libonacct Series. Ansi- # tnelude inf maind { inf fn} ive tico, t2 51s fw rele = tht t2 4K Printt (“Erker tranumber of terms? 9. Scant (*%d", kn); Print( (“Fi bonacel Series: £4, %4,", 142); for (1=%; Pri nff C7 4d," mot term) 7 lesan soar At = 42; dy = nobdum 4 nowt term = La4t2; hee oO; 7 le oe compara ve Study between ir Q-3 wy may PO\VY ark do-wwle (op. Ali—FOW Loop | while Coop { do-whtle teap 1, Syntax ¢For(ini-| Somtax s wile Syntoy DOf. State Lializakon condi Coens aie iin : ements; - co j ion jupdatirg) }. Statement; } 2.T+h known ab| it ts know | Et kk known oy entry controlled \oop. entry controlled loop. exit controlled loop. Hime wil never enter ie Th the condi is not true Ffrst Hime tnat control Will never enter iw a loop. Even fh the conditic is nob truce GOP th Fiys+ Hime pre cont wit enter th x leap a loop. ical A There Wh ro Somcoay abter tae condition fu tte Sgntax oF the Kae tor loop, There uno Semi colon} oyter the There k Semtalen; atter the conditin wrndition Wm the Syntax ob the while in the Syntax of due do wile lop. \ovp- S-Trihializak ow [Triticligotion and Tui ficrliza Hm amd ond ae s updating is not [Updating is va} doe the part ck oe the part of toe port of tre Syn foye, Syntax. Sgntax , Foy loop is uge \uswrle lop & use do wwile loop bluse yh WE We kno doel une we dow i 7 td umber oy iterations Kong Hina ruunbor vt eee van 4 Here tne. lap o& iterahons é erations means caminate | moans Wheretae lyre te (oop ay write a programe m Cc print th Swe ote the Fall owing, series (ber n Aeris Where on Yrold be given ay wser) vee A indude <4djo.h frt rnoin C) { ink i; Factorial =1inj3 Sumo, Print & C Euter value for n "); Seamf (“hd" Qn); for (itis igen 5 ite) | pacforfal = factoriol wi > Suma Sum t facto vi og : Yeedt Copa", Sum) > prebamnoj WEE ile Hime Ar routes QF Whak owe Compile fj Mo aay He ar Mh compe Hone orrery SANTO 4, Compute Hue inf Halizalovw, ger nos +0 enter the Acti) jy wne progrom itsere Compile Kner iMihal2how ww Some on Variable Inthaligehon Tre gener how of inihaligatio ap anay is as fellow ~ Syvtay — +ype Wow? Ceizey = § Ust 0k - veluey M iukeger array inihaliza tor ink roll numbers (4 =$ as 674 ; UFioak array jnitialigahow foot avea Cole $234, 6.8 56, 4.3,29},; JL Cnoractey arroy fWiHall gation. Owe name [a] = fer, CU, bya, 10? ES Example -- eof. # includes thio uy \o } Vad moin() ink arrayls) =\uxsa55, bot fi 2s Print & (“ Displarging, arvoy ot elements 2 72 Grud ob 308) FMD, OF. , 25. oo (o= = bo97) 4) OB pup ( mom warp OF ae amin ™A =D dwwoxg flea “woyrund () yuvds Sun ay punal po rp ady neyo! 29 op WoW Protve UY PIYYOAN Se@cath) zt pry pds sam iv shosue bavi cpens Gus! raz y) op Wyre NM My Aoy orn ayy 1 tT C1 = Soy Baga son a oe ened: st WIAD pao lyse Bola ee MA zaphoyy angued ~ s0h3)) 970%9 qb wo dom yee nv ME put UNA & fos eee Bun = re yex ney, Pras mt wma | \ nee ae = (ped OD) 9 a. ayy ITP H+ ~wotkord ~~ Dtran Ea “P aag hunk otoy hp ab ot pete I) Sbett, Brossro Gus phere: Ao wo Buibadng _- Me { { ©(L13 Proaso <4 8404) J usag {G+ to7, =!) Dp { fp vdnfor fou Pn) dtd (ul ¢roqumu, yulsd Y at i “y oQWm grusad ~@ WP "he a) dd ay write a Cc program —o find €cp and Lem ok two number, AS He includedsidio 4d Vaid main () int a,b, 4k, lem vemainder, numevatoy , Aenominatory Prinkl Enter to number» \n” ds Seamt (84.4 Ld hor, & bods nuumenatiw =- (a>) eee: deno minabey =(ag b&b) 2aibs yemainder = numenra to y % denowmi nalor; wwile Cremaindo yr, =o) numarat yr = denamenate » devowminabor = remaindey 3 yomainder = yumebater ey, Leno ménabr ? Ged = Aenowinatr, Lem =A*% b/ gcd Peet Meet a Jd \wha, yg Privd lA LEM of ad anne a" d= ANN ab, Lem) ri |e $y of wife a @ progrom. to PRISED print following Fibloomacci seriS 423 58. iS” — 2 include int moun (0 ‘int un int dyed, treads ink noctlerm = 44 42,3 Print? Ci enter dee number of forms 2 »)} Sead (8% a", RN) ; Print? (*Fibbonacct serith*Adjfod, "4 , tis for (ics; teeny te Privk? (Md, 7, Nectbermy) 7 feta s Lae yurtterm y nator = t1% 5 dag ai 0, | 4 | culputs— Enter Hae number of dorm’ G Eibbonani Series: 44 , 23 5 What &% funclion prototype 2 Ange — A funetiow prototype a dofiwihon thot Ve used to por form 44 pe nscleting ow funcharr calls when tro BOL System Cade Joos pat Wowe acees&s to thre funchon, Mself. &4:- Wrike a pro am to & check a a wunber is prime wit, Ad fur iteratows O% posible. pate Answer & Safe (here) Qyor— Difyherent ate between wile ond a connile. Safements wll suifebre do while Joop Thin (oo ; 4b Unecks Po weil) execufe ce amd anor exeedes Ane statements af least Stakemunts : ME) HA Hye Cond Hor uw Creeked, aw tags FRR Bekele adage nel ae 2 clo neea to mot “orakeds , ] statement) com be exerted zero Hes tf Ho condi gH felse. state mt i enecubed at Vest once. ae Wile loop is writen] oe (condition) f Statements ; //loop body J le Lap © 3 = —(Prink 4 eecopiae?) | # tndude <5 rdie- » A Weds CMO’ WD ink man O } ink nun = 1; Hinkalizing toe variable with value 2 Wile (numes4) /) Wile boop i wits Condi ho Printf (“7% an’, num ) 5 Generally do Wile Leop is anrittert ose a statements} // loop bedy y wile (eondihon) example £ —CPrink & fable q Neen 2 # inclukedstdio-h> 7 included comio bs int main ink pum 2 | 5 11 ini Rol 2vg toe, variable with value 1 do / do-While loop Prind eC vd \n", 2* num) , mum +43 //incrementivg opooli ie taj yhwihalizing operohiny wale (num <=4 ° yeturn 0; yvelurn 6," 7 } y Oukewt v= 1 our-pets- 2 2 4 3 b 1 8 ein He Wribe a C progr t= pret her Fellows, patherw + a 23s 4444 AMS ip clude 2 t4di0. o> Bit “mom () { ine Ky fore (fei, 12-45 t+t) ; for (KEL KS E4z1S Ktt) f Prinf C7”) } for (ies ixais itn) { } Printh CZ Mi )7 Print f (“\ m7); yelurn 05, MIDIn verida, & program 40 print pattern’ . Q ce as : =—— 1 ee 4g ae h 4 5 C 4 & a aanee sts od “3 opel og 4 ad wow ad ~ : 9 equim wu A0§ 39 smangted pwr 89 499 versyyed “Mt a pour of swarbosd ~~ AM FG | Bmp rt pied op -wosboad FY YAM as Gis ST Wrthe a progvom fo prinh prfellowing- Pde ere a Wee pe eg Awys 7 # include Int moin O na ; for (ing, feet (=k Soy (kelsncetds wre) 4 Print f (* Di for (iets G42 GS jer) 4 Prine UH") Y sott Cyn) Del. 9, ¥! A. Le weWrif@ ow eregre™ to print th Fellow pattern Se \ 23 gk + 10 AVS’ # include te Trt motin UO (nt Count = 5 for (int f245 feeds ior Sow Cint jet iectidtt)f Print f (“7d 7, count), count +45 3 ) veturn OF } Print fh CVn?) i Break statement Te byaak satermont is used to exit from the 1@P Consheucts, The loreak statement ts usually wsed wit tne Switch Stafe murf , ond be re 0 use te udthin tee Wile Loup. do- while lesp, oY the foy -loop- due va\e ob pritak ond F l continue Statement Fire continuc Stofemont & nor wed to exit frome \oop construct ne Continue statement i‘ nat used wit We Suite. sfeubemenh, bub it cam be used with in Hae wwile loop, do- wile loop» ov for |p wh & break & encountered drove the contre! & exited from th Loop construct immediately, Zymtan2 veal; inte words use Suited pak’ statements use Suhel own whe stelemeuly, fatemou Uf! Adhowe Hee combine Statemowt is encountere’ then +e contro} auto maticlly passed tye tht kenga of te lovp state mewk. Syntox Contac; Tt does AA cue ard aloel Stabe monbs «a oyeomnp)e ° - Hindude

You might also like