0% found this document useful (0 votes)
7 views38 pages

Loops and Array

The document discusses the for loop in the C programming language, emphasizing its functionality for repeating a set of statements a defined number of times. It outlines the advantages of using for loops, such as ease of control over loop variables and conditions, and their common use in traversing data structures. Additionally, it touches on the structure of for loops, including initialization, condition checking, and updating variables within the loop.

Uploaded by

ßhřéy Vàťß
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)
7 views38 pages

Loops and Array

The document discusses the for loop in the C programming language, emphasizing its functionality for repeating a set of statements a defined number of times. It outlines the advantages of using for loops, such as ease of control over loop variables and conditions, and their common use in traversing data structures. Additionally, it touches on the structure of for loops, including initialization, condition checking, and updating variables within the loop.

Uploaded by

ßhřéy Vàťß
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/ 38
a ° i . ~e fox loops OThe for Loop WV C language provides a fonctfonatty | me fesror torvepeat a set of statements a defined number oftine- mp © Aform of on antsy controlled Loop » me © Ine moin odlvantaye df for top Sa Wat % controlar the Pnrttalleart > condifen and updating a» part of Ps Aight oot asta mates Pa @ kit afmpler and cous af ues © Mdiauy wed fo traveue cuaya vero Rother data structures. me Satin: sqquctunst eOTON OL nite 6 2 4 ° © Trfollous ov ee ao unetaien, ear caraion| 5 update) Zac appfoaeh ™me ober tt beats wrth me bods af for Loop § fntttarkaPngy a cond” = % cheek the eonditon g Swicea enceeub ed condor « Ararenents . Ge Ryusei Retmaed bg psy ee Plan osbataiees tt + Taktabiaaston seth step Fntifotfner a leep Wiel vasiFaune woth me on RG Vale that Arapa to progress tne loop oF helbs ata) = rene g ne ondftion may 4 Tt ack? m the Tndex vodue ren Frenating on corey [44¥Fre my 2 Cer Tat Ogrenston 3 x Shik step Tf me for oop Aepinet “tine conden What deteamther voheth the Coop Ahould ewnifinue — eneeukha oF ot. + The undPfen fh wueetced before, eo eqprenton- Theation and FL th fale tno ae fessten fh teunfnated- ‘ a Th tne condliien ta true then the Froiatton Cie toop contr: wed uch and won't Atop unltl the condition beermer false. md 5: Wd? Th Pk the ack af Atasemen Tee Vaxfabtes, functions wed okt that fe created Hepeasediy HU the condition ta true eo Tt ie enctared vith bracet. Qe Updatton * This apetffn hour the Loo contre vartatte Alould or ‘al oyrer cack tenatien ‘annie cyononatly FM we ane Rreremantarton (vaxfarte ++) ox decrementation (vortabte—)_ mA ook Ane WOP control yartaurte « a yr ing % a tne bute sep of - Supt Tritalliotton : fot Loop and occur Gry ence dung e tneatout of loop: Hue Voutanler e orn dedoreal oY cuntgned « — Stepat tonditien Akad ane cherked Renly ey condtton @ fx true tne Wop Lott be executed o Line am condition becomes Fre Coop fre gg steps AN ane Are: Prufol Loopacre. ee ep lodld eet sen panera, Oe ye ee oxten updating HEU. (ob f B72, gg -y advardaqes © Provides code svawaniltty o codertee dere ie Jroueting Pn cloka Atructues Bue aay and atatng eeomes gay» waving * Cont Ap any Braremunt wh le —— © my a ACN le conditten th follovo ° 4 = & = & ox s = oo - = - - ceil Brampe? se %nctude Gi Hele : ue Hole Soe fat matin C ) * Welo + weal tne ts i for 05 L428 5 4475 5 wiser : prtntg C Mewes w")5 rend 5, TaN ehrnel 9, ~ Qs AC ae we oe da prtaring oe MO x “nclude mp int mont) fete | ~e t Hey, £ F m ¢ ~ Pree Cena = ys , =~ Acont (ra, an) Pa Gea) Cezivo 5, r+) ~ hy (En; Le town 5 &t=n)5 a Utnee= ay patmgl 7. y.a\n') a nA 2 ~~ Ps ~~ prime Cyn det eo) 4 ~ 4 nun 0% = HUAN 05, y , ~ -for odd — tLerat=% ~> AQuypuss fente N= 5 rae u erp Sceut 105 Aime 75 Can Change Qpenove 8 con dition yee and wen print Ce “| = R (E15 f4v0 5 tet) a ——$—$<$<—_—_— _ es ae painty (nya) nal)} ws ct tne foctortat of aa = 4 gtoon n+ Soe a “40 bx Ge Sh Aine ss festde fos) fat makn &) & 24s ” = an rece Gat ° mn, Past=45 = Qa 5 Paty sum tf au mola Fo agtnnno: printe Center ne") MD = x fncuide Cstdfornd cet a) a) Bn a co bute < Acang O70", 2m) 5 a Ent 5, @muneh for t= § Cem 5 Bes a in ema 05 Gum IS to prtrag Cretan 5 fost staat 5 =) Acond (d's; B)5 4 =a For (t2 45 fens ot) poling ( Facts po = puhon 08 , a \ Aum: aunt € 5 4 - patape'vn dum= 3 AW), Ourpars - nun 05 ‘ eMtea n= 5 Javtorfat = 120 os i a a al ¥ ial SP Weletonp + SHU aprerart loop and an entny controlled Coop o Te fa. wed to Heraste o& part af code untll tf wiiie fhe given condfifen Yemains te "Tt tirat tat oO apustfied condite Foire, on Wong ay Pt venaina true, be exeested (ag Bruce? Ty folloet a Abructuud a top dow? op proce Ue o- eral exprasion Prtueg, | Om Lnop ody Atatemments “TU = oo: Rirtost aston 5 qecntlatfiaion t47In au Alep » we ~- yowle (rat orp) fritialee the lop yoni 0s Gam frPtfol Value « pe t aT nein Caan a we Kom Pope €n ter tenpe one pe aN Ee a ee Q- conditenal Rtatenent * ou tt checidler ureter Boag TH wile Loop 5 wapaieren 5 rr \ ae Thin tA One me matt couctal Ateps = the lptocs tr we whFle Loop Code vot exeuute« — A The widle oop body watt he exeenteal tf and ery ae &- defined eH eondtiona Afatement & Te - om te ~_ tert eondiien dhadements that will be 3+ Body: TR tme oxtual Ae of ecified condition th met [tue. at geealy exerted HU Ame Ap enewned tH & % broees- ro 4. Updatien SaZE> tH ON exp Teton hot updeta the vame ~ Fhe Loop voriadHe $y eo tteration . S y We vad define t cupticitty th fe body a ; ) ee ee ee mg 2 Propels wulle oop * yy mays A condo exp: th ured fo deck Ine conditon + Ihe statements delined fratde the wlale loop vot ‘repeatedly exeeure anil the = 6 ator condifim Pat. &- the gondsten ust be true “t tk vegunns 0+ me four wt BH metus ONY MON~VeA0 mun bor « me 3. In eaitle Loop wnditfen expres fon & mecemary P °, mB 4: Running a stile Loop wat a bod Ub Pole. 4 : fon Most me D+ WE Can Hy MoTe Aman one conditional exprenton a) le ~~ : ‘ Shetondition wil be ~» leo Pp aa e+ Tf the op loool conto only ene Alatement , Hhen the ~ Vrracet ate openat- Qo Prints te 5° 8 Reese no QA Prtrigng Hallo woo Hines Finaude Cstdiow> CON = oe Rae ; MD Frauele Ent whoo LYE oly = 3. ™e int maint ) f tot 45 sear i Page = fim usta te (€4250) maf) “= a (ese i) Rey D5 Put C=a05 =) Hoe, tte (2>=0) AE (AW HUD") 5 : oy a )5 natu 05 Eng a mm, Z 5 Gee =) Aut 0°, Qugpuhs” Me Amc sie, ° = A < - cs gs facta af gtuen meet Qs Sum of oll no's upho a given "0: “main () EN gaspar z pe Cia — Pav, &, Jacked 5 — are ra Aum! 0} antan= 5) gle aint gC enters me Opting Cena); um= 1 aa n)5 i, Atong 7a", 30) 5 pstste (an > els Cen) : - Aum = Zumt 5 Fost = fasts C5 ai C2 trl5 > eee sok baat U Sun = 7-0") SU9)5 Brinn Uigacroriad= 7a) Yar suum FA M25 tnt we NANA 5 Qs Te_petnt Somaest Ault * a) foyer aa Pyctudle 6 statfoot> by wwhlie Coop ety nde gsteloe lS Pe, Ren spans = fr masa CY Put main ©) a $ 8 o ° p c Bint Pee rrr 1 mm, &, NATO, NA=L5 = PAM mena err ment= N45 = Onap eM Uys pring © enter rumba2'); « prtand. Center mumbe=") 5 Acang Con, 245 print (UF fhona ce aedes stank Wd Awd") nt 12)5 fox (ta 5 exentig ert) z Acang 8", x NWN) 5 e satiety ‘ foal & Vd\” ed m4)72)5 oe a a ~ Pe (eee mn) o e print Pd “mertys 6 4 niece Ua a print an fd", MOK) 5 MA=n2 5 NAs a> maser « HAz= NewS net = nda’ 5 on 7 Mest= NA+nas Ula Ask) 0« " Astunn 05 ~~ Q+ A numba! comtaeng #8 z ~s see ees bh edd she sddeé Cy bare . ) \ | J a \ (yy etad el ehlnete, ASmauude fat marn 0) ta Pak mn, &) J Pep $0,005 prfnre (" entu N=") 5 Beant Pd", 195 temp = woWie ( 7°) t Cem f05 QT patnt gum af alyttafory noe Blo creck Mo’ fs podindioms oraet- Fm o e .: RPcdude detdKoe > ay include fat magn ft nade) ¢ a b 8-0, temps ° 20,6, Val } m 1,%r be sch OE prints (" enter n=") Oe printe(" erie amor =")5 (na amen; gang Crain; Can, fa, an Og yng 7 temp= 5 « Vad= TUM 5 woule (M0) - ustile (mwmn)= 0) $ & ye N/- NOS) e n= Num? 105 S= + Gxto)s e Sum- sum+T » MiNi; o < num = mus [18 5 = y joer ef : Pp (Az = temp) ~- prfntt ( Sum sf.disis=/.d 7 wm); pointe (" Palthdione Autun 0; euee ton i pretf CME on Sulput * @ntu & no- = 565 Datum 05 = Sum: !S i Quip ats enter n= \x4 Sea QA moth a oy mat: Posinclome. a SS Facade (std. > SPrTTr 4 ° 2 “i maint ) C eflaonen) farm, CVE ee pot ed M peer, Md; ping erm "95 1 gue Bean p 74", 29)5 pata wile Pen ) t “yeu 05 tune == OE 3 hums gum +05 aoe > as ~» Q:1°To find veveac sfonoe = ‘i ma Hinctude OSES TIECI IIE me cups FECL bes ddd oT fa ahrntlan QJunpar ® ft maf \) Ft mum , Ye20, 3, VAs prints (" @nta no: = ae Kcan$ UPd, BAM) 5 Vah=mun 5 volvie (num |= 0) OA a td | Qa Gam f even rodd Wn fate Hons \z ifr cide fat math () é Prt num , S=°, 0820/05 | fate (an @nte ma = 5 Acon (Wx ana) 5 for(G45 Ce num; Et) g aeenn==® g ys num 7.105 a dae cgay VEU NOT, ; ne 2 num > nwn /\05 miele . ose Btls prime Reyes "= 7d", TH)5 y nitwn 0; or g rt ca aun 2 1A", a; 6 ” 2 hd", O95 ryinst (ode su Ad", OY enture- = IP une) UD Ruse r> 2) | TE Do side loop ¢ CE oTy ta an ox controlled os peat serted tooP Pb cheeked Of This implfa thot the Atotenents (9 be exeuded atleast Once jo 2, When th hel = Yo tne devdte loop ythe body of he Wop. Peters cond” fa cesta unlthe othew, Due 4othis , the do -volile Loop foal ‘to enh} warroied 0% [' ow c body of Loop 5 space Cundttien) 5 fo votle Loop GED except neat the tert condi zur executing the bo : wi, Uitrmo = 1° | | @vensums | | tne Wope | fy dp- white Loop at ‘oto anata wobot tyecand” id= ogrram contre? fysbcomy, Fa erceuted Prat and then & owen the tess cond” fe evaluated O& VIUR | He pyOg VOM = control gees to the staat tf the Wop and the hay ee emecuted ence HHT: oth Til the tat condi fen fa true. p* cess rep “the cusove abtion £4 evaluated ot fatie \ the program 2 K over HE sens con = controls me Ga On jo the med Atedenenh offer the do-wtfle Loop: = 74 Ryaucton ITT ~ A+ dot This DE Sntores me de contle Wop ond precedes tre Sm 2 exeutted Lotinin tne Wop: Gem blo of Batons + b & Bstys The blow Sf ArsdunentA conitien Pufde EY bree ~ Gam ko mee the do vile op mult he exeuted — qa fovat yh any cond'71s cueckeed- ) = pode: Suis usqaror A apeetpian Jye on euatuated after the axexution sf Hae loop boty. - a epndifen* sind, Sh Ae eoprenton that deteuntner thether the Loop should continu Cheratfin g OF rate Tf the and” evoncked 4o be -teue , the Woop wontinuer rt tt quatuara Porte | te taop teurinates. datten fe mot a pas ef the Woop ane Loop — dision, +0 be wa The nif ovisarion and up Ayntan 6 oe ny 8 do that emp Viol tly. before and.th mresperttvdy . TTT a2 tind Guy of Firat’ mat ana moh 4t finctnd eatdfo > mai Qyrte print Farle of eae ‘te Trctude Cotdiown> = ~> nen Pt main ) me int man, £5 fon num, Ca, ong temp 95 poy ae)» Brg creel ~~» wy gt anys SU x ‘ - Bean PUA" 1)5 Beont ("7d") 5 - Cen, emp = 15 do dio mr ? © re e . be SL Vee) a oe eer? %) > Crs ~ ee 5 wie nr) ™ Bevataie Cvc= toys qwg > k /+emP s prinag Avg = Jodo, cg) ~e fi a i poly * 5 > = a Brean Aoremords mH rwn bh Cored & a toop sora} alement which % wed to mtvot oul Yf the Loop bring We mcogrem » yon wed tude ops ov Aurteh Alcdements pres karen ont Rh qucounternd Lot tnin loop, | AS foon O% MWe Hie Uep Teroatons fope tnue and wrrrol Car nak {vom woop imtmedionely 10 ae first Agena oftertae oop 6 aga Tn car mated Loop? G pteads tae Inner P & proceesU Journ Lops: Qyrtox + enample® e [1 oop 0% Awe cane ft main ©) break § fox ak 245 e105 bre) t hand Men ay nctude prnte '78", Dy; tf (az=4) break § nreunn 05 oupais 1234 Bs o = = = & & = & es = < -_ ce So = Worwing’ te The! Weak" statement world Ainilenty to other progy~ -oonming longs a Ww «programming. The Woop 07 = the gut glasment bert, axenunten. Rs The program anokyrer Hye condtten wrt sal eR "eaten ent (en othe, contre fw ahatunent) het Tcucleh He gi “peak” Rrodenet Xho ut On Seonpkien of Anutnop or om eock check in the Avsttda + 777 mee: TP the condition fh “foue™, the brea Atokement §h portermeds MB. when a break" Atatement te Pound, the pro rou qui $s tne ~» Loop or Auotth the blook _ App en any Phenatons [eters « MBS The Paoagom contfnuer to eneate tne code gelocigs the oop oF A utten . . fe} BING benetiefat os provides Cun eppialent ws0y to ech Coops FA Or sutich “Lous When you ov Toner need to perform ® fuurun Toattou. oy edu AQ wad to a) gtimp\e WOPAs b) Nested ops 2) Tndnit. Loops “— Mokerressaues’ ) A) Rutten cate —@n-2) av Sie a aR dude CStdforh> Pri main © ) tnt C245 : vote (feat) y (fs: prctetbtoeps i dood as Hinduade €gtetios b> int man 0) & = = es tin tag 835 ter) § ypeaesyre der ees wR >=a SX S>o=2) 2 . opeak °, 4 pats O Gra! Bie e : = 4 Quspuré rae Gj OinCee 6, : * (ote Arotemen’s 5 ee eee proutde - i oe < © gov grader we peyeami, jump Bron Me goto" to & Maselted 4 sregement in home < “The a smut con ee to as ome parr ofthe Codes pont cular ondition 4 = + Trcon abo be used to ores he sii woop pees - - pe done by using a. ingle break Aratemert e 8 Howeue, Use g 4 pro cramming ghgomert TA Myon lavt Can be plat Vent eccept COdaes @ tumyurirdy, Mout | can be derangeshos fr le © program Muny as | { peg v1 below M jov Arosument'e Qatnaude Lsrdlor> fLowiran Ge fat morn) toms faa t 6 a a ly : Bre mum 245 \an ey ' prinng (Senta n=W)5 om 34 3 ong ya, anus Lontes, i patonh pd a fd = ann" ron Fumes tat a ~ Q ic &=\0) axcontinue Rrsurent ~ gexs Aare 5 © Waed 80 ocing Ane progre™ “~ Control +® Ane Wop s me ouput > Emha_M= 4 [> Somestod Aiinilay 40 be —~@ . ur & forces toe Next eat s= Qyi=4 feaie \ pruteadt BE AtePPT} =e Uur2=8 we place | + = ua set * Mela, wed ADAP Jor ~ — cela Conditen go thar we Woes can Aluip Aome code for posicul = ometgis es conc eie — UR ae a winuade egtelion > — gh = ae =) Ma maind) & 2 ! ur oe 38 fos Og cet - ae pring ya sa) (PANE -"p) Se 4 tein boop Aroremert % ; a a nucs nun 05 ' i. -" 1 gone Une oh mecode to be silpped 4 y24s DP — Ftowensits zt Coop oe Fue ® Rem: p cut Gf Loop bay = pee eo? ese ey me fh on ha evileetion af dient tan ype f'dara x ee ~ ‘ype YA Called cement x an Ary. me ring: due dedued data Hype fc weds can Atote the pitofive Mp dtta tape such oa Find, cron , doudle feoat etc> * Thatio har tue capasili fo tore the collection data a ,AuchoA pointeu , Attuctue Ue « aT Tone used “bo Above mudliple yalHer fu vorgable , Gnatead of aedartng gop erase vartalle for each Vande ° Ghe denent of on og Aho te Aone vantoue NUM e fut cath cleonertt ha, o si}ount Snden yum ber unovor Ow subnet pt - Jhue dota eum Cu be Handomnly acceseet Sa Wnden Number- ahora The data fin eontiquous munony Locations | ak detued a rtng\e by win + ACs 2 To creare an OM , dahine the dado aes (tnx fos ond cpeihy the Mame Uh the once Followed 64 Aquare lyvackes - A oe | = To Wet VARAU “So Ag Acs CO ~Keperokedt Vie, peice cunty pace & ea num il * Bas, we, 465945 eee esse b bee b bd AH Aduantopes fe Code Optimtraten s lew code to acest the dato + 2 Gare of trovauting ¢ By uatng the Pov Wop , We can ryerrtue the Qhements thon Ahoy casi, To aovt the atements of tae ; we meed 0 feo (ne Bfeode on : 4 Kerctom fecen 2 we can accent Ky element 2 tartonly, using the ann 0% tndex. st prsadvantaye ¢ ipedvortey : . Once created , ihe Alee of amoy. can'the 4. Pred Kees 24 | rer Bs Kare f Sorting ¢ ae Merry waste 2 Tf on Oe th tanger than neeef ed amen 4 tk Wartesf- %. Limited cata type pupport % Ariroyk con ony Atove the genents af same data ty pe. 4: Pack of dlentatifiy 2 Arrogt ant ler aclaptoutye Ati tran xkruchue Ure (Giicent (eh, treet ete. at C-Avoy Dermrgtions Opeararion Utue ang ofven vanferb{e. © uc con deadons Py ty anette mama =f oss Rar ie = sie Gyrtew t datatype anny ner or preginen: Oat = = = = - =~ mee a = t= = & (- ATTY Tyitiaisatton & a oe ; o. eTyit ahah on fs tne pce fo cusiyn ome fultiat voine ae VarTorre - © when the @ he W eee ° Tnttaliae Me ose +o forme meaning fut vaure. Sa tvalts ati en votin_p etousttion ster declaration, Ve “We woe fe To Ag we we on Pnfatiber ut + fittotae ~. =e - =—— me) ie “Retain Wot Pa the \en atv ame SY brack dep tases by a oomm4- ™ intan. data-*gPe oman - name Usieel = Pvas vary va NYS =. ee omelet = garter te 4 Og ant aAtasaton wn peuaation wilwout sleet i ie | ee “ Btu = = oe 6 th declared ov clincated memory the Bement © conta Aome qarbare Value. So we Neel te A multiple arements & qua enuUored ntti in ie oF = Ww 5 + Tp we erate OM win Rafts Uat , we can akip detaaiing th on compl con ustom areallg deduct he wee fn Mee Cue - Pin there cares f eqerat to Heme af oThe Alte of she eons nent thy the, Sritoitcnr iat Os the comp! lu can Oustom abfcalyy deduce He ste vf the wre amet eet 5 whia Ps aie cpt Gr omy athe size oh awove ase fs deduced L hy re Le x ANS Ain, changing tha clemen anny « BH Ainande (stdfoeh> SG we can O2cess Ony clone y fn mein U) dfon oy fy Cusiing Ausertpt op ester im pl £19 “5 C1 and ine inden value, Baer ergs) hes Gg CE tel = 2 ° cma - namel findexd 5 y & printg ( pa", atl) © one thin + wote Hut go aur 05 she Fnclenng tn He ons , Pike Ktoat wht 0 fe. a iggt Cement fa at re Oe ost abomert at r— Quip * % us ti “\ pole Nie ge element %h tHe att 4p - am nee woah ne aubicrt pt= e nton, datatype apsay Nene Tsiee] 5 — eee nen oe led time) —— Gk a Os = fl, 25455 retvaiant — "7st se ae < cman dal anc sem oo ee ei oe ce ud ne et on BY Ah TON a atta pie progres 8 Gm give ane vale vy ting Acan} function Pa We ee lone wie ae oN Ef oop © ©, int BISA, &> Ss IAGO E aUeE Ea tae s Ube Ie eES \ Suma ef ol m0 Wictade Cetebioe > 4 \ , , Pat a, Awneo aug yr Atioool § print (Cente a= ')) Kean} C4a" an)5 fos (ko 5 ban} tra) e sont 43", 200) 5 Aum 2 fume AUT 5 wg > Bun|™)> nid Nm Aum= 7-4", & Sum) 5 end aug 2/4) aug) 5 rut 05 j Rind Pian [min ofenent <> e 5! ale —-.H = 5! a eet SA cae ee - WS Ans Rak f, mary mies ASE 5 Pa on [reels . mimad (" enie, alee = We Beane yg", 2size) > tatt Cente cement af aus feo fa gor (820 5 Pqsttey 4 3 sconp fod", CORED} i aterm! mo’, and Pind she x Qs Ente oun ww’ fat vou er Z Xfind Me dun of wits [odd nd, ° % Wincude detdiorns © ° Tmt man) f int Cn, AUooel 5 tar Aum 20, AumO=05 print UW enta ns DS Seanf ("78 anys fo (S05 fem 5 Cee) Acang (17a, BATEY)5 4 — for (f205 bens tr) é TEC ACCT 7-2==°) E Aum E> sumet AUS 5 a | oes O02 aumor ACTS j ; ; norun 5 Sige conan 1 ete one BOK mins amr (Col5 ' ° Peale 5 feos Cealee 3 ; for e205 ( § -_i@irn ' man 2 ombl Ty Gow 1 amin) amin z am | i+) i | | ‘ MUL’ wsruioual ay an ey annays thot stoves homn- -Trean be juneal as OA ee dota I ne nut ple UAC PE name Csfzet] Csiee2J — of 2a dim”. © J+ has > Syrian: doraty pe Oe _- Late Nae | pote Spy heen” giee gy avamny — fre om [rojlied 5 A Sp awey — Pint Osa [oy Le3l* I 5 » Sree yruilticli mest onal < the fora wo: of homers Boon be Coreulated by vw Hl} Ate of ou binnenion . x wt atoll) > alements = )0¥20 = 20 Uementt. ait) byte, % 3 5 Fo qet the dice maul ply the alte op single alenertore Jota! v0: Ff olerrents Pn He amoey a ee Mr alos lr} ae tnt = 4 by te. Sizex= to snotY = G00 bales. at ap ores ¢ » Sfmplat fore ct walt. Woy « * Cynton lato_ty pe 6Y datatype sno CURE ere a aie sf vous aye mo of oll 8 pour munbe. Vangel frem 0 to (1) cel w-. name (Size piace) J e adie ror) : ected 51 45 curv Pat A’); AeangC PTUVITTUSTTTTOTIT ETE \ ee . ~y for 203 (crs tt) ™m ¢ Nott 5 In orda to wi fro5 J¢ 2044 me . : s pe BS I) Catal! ame ("> Bere wacadrfeet prinig(’ pare”, FIG) os a ; protyia Auld be patra te “ys +0 0 pours sf 2nd wsatyi™ Notes 4 aston 0; Creat: oe Act tedeeuae? —-- Que 3.26. | Write a short note on manipulating array elements. Answer 1 2 Sd ae Once the array is declared and defined, individual elements of array can be accessed in different ways. The subscript in the square bracket indicates the position of element in the array. All array elements are numbered. The number starts with 0. In general form, the statement var_name = array_nameli]; ‘ is used to read data from an array, where subscript ‘i’ indicates the position of array elements within the array. The data type of variable and array must be same. €3.5. | Write a C program to add first seven terms of the falivering Serica using forloopr/I! + 2/21 + 3/31 + AKTU 2017-18(Sem-1), Marks 07 #include #include void main () { intn; float sum = 0.0, a, i; Programming for Problem Solving 3-5E (Sem-1 & 2) elrser (); printf(“\nEnter the value of n : scanf(“%d", &n); for Gi i int main() { int n, reverse = 0, t; printf(“Enter a number :\n”); scanfl“%d”, &n); t=n; while (t != 0) { Teverse = reverse * 10; reverse = reverse + t%10; t=t/10; i if (n == reverse) Printf(“%d is a palindrome number.\n”, n); else Printf(“ed is not a palindrome number. \n”, n); ea 0; Que 3.9. ] Write a program to generate a following numbers structure = 12345 1234 123 w AKTU 201’ 8(Sem-2), Marks 07 Answer | #include #include int main( ){ inti, j, rows ; printf(“enter number of rows :”) ; scanf(“%d”, & rows) ; for(i = rows; i >= 1; —-i) for(j = 1;j< =i; ++) { printf(“%d”, j) ; } printf(“\n"); ) } return 0 ; Queso] Write a program in C to print following pattern with propriate comments : ie ® ‘765, 4321 #include clude i 3-8E (Sem-1 & 2) Iteration and Loops void main() { inti, j, k = 10; elrser(); for (i= Li<5;i+4) { for j= 1;j< { i++) printf(“%d”, k); } printf(*\n"); } getch(); } Que 3.11, 1 Write a program to print for the pattern : sees see ” im ae AKTU 2020-21 (Sem-1), Marks 07 intn,m=1; ; printf{“Enter the number of rows”); seanfl“%éd”, én); for(int i= n; i >= 1;i--) : : for(int j = 1; j <= i; j++) { if j==1 | | j==i || printf(“*"); else printf(*"); } printf{*\n"); e Que 3.13. | Write a program to find the sum of series using function, U+ 243! +4!+............mterms. |AKTU 2021-22(Sem-1), Marks 10 Answer ] #include ss int main() { Neg int num, i,j, fact,sum=0; //variables f printf(“Enter the last number of. series: \n”); scanf(“%d”,&num); . Mast number of series for(i = 1,i<=num; i++)“ oop for finding factorial and sum { i fact = 1; if (i= num) intf(“Zd!+ ”, i); printf(“%d !=”, oe _ for(i s Aj <=i; jt) 9 fact = fact *j; sum = sum + fact; } printf(“%d”, sum); return 0; ) {que 316. | Write a program to print the pattern 1 2 128 1234 123 2 1 AKTU 2021-22(Sem-2), Marks 10 #include int main() { inti,j,N; printf(“Enter N: ”); scanf(“%d”, &N); // Prints upper part of the pattern for(i = 1; i <= N; i++) Mae Geen Iteration and Loop. i for(j =1;j< { printf“%d", j); ) printf“\n"); ) 1/Print lower part of the pattern forli=N-1;i>=1;i-) { forg = 1; j <=i;j+4) ft printf(“%d”, j); } printf(“\n"); } return 0; 1 Que 3.16. | Write a program for pattern seene eee ao sees AKTU 2021-22(Sem-2), Marks 10) ‘Answer #inelude int main(void) { intn; Printfl“Enter the number of columns”); seanfl“%d”, &n); Mprinting the upper part of the pattern, for(int i=0;i

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy