Download as pdf
Download as pdf
You are on page 1of 27
>» Loops ant tue +o Hepeat a gree of aderment naepeoted Ly ein c pr ogHiomming - (for Loop + > The por Soop 1 used +0 gerovh of statement s1eptod edly > Td exprepes with toop yoriable (4) > > The Symtox of for Loop '$ given Oe follow s'- eet us zcthion, corci#on, indyemsnd [| oK Loops a Loops ane of tri ty pee execute Whe _ Syntax for ( initials os cl crement ). Group of sHiiremenks ? Dot Where initiolizaHon = ctonting value. + Condition = ending vole off + Tnanement = fet os js f4#t. © Decremens = i-- ste Pet Qu: Waite a program in G FO genirtoste ie RIBONAce! SERIES Seid FE tnelvots ¢ gtelvon> H- IIneluotse Cceninh? Void maint) & tne ot SCaonh Chol hed fol" tq, £675 Z for Po : 3 : gp. Cet S185 yin) ‘ Cr arb, PUSHER fol", oy a= b; 7 Stuap values Sune: Lunes Boer? Wotite, a program jn ¢ to Cheele Wrhuthin HK nes in DRYSTRONG NUMBER a met, Sol > include < Stobio- h> [Rho of 44g te inctude ¢ Void maint ) to 2 N/o+ ocf Loo} int 1H, Summits Seanf CS ZA" End; for( ian 3 Miso} ‘=i fro) ; 2 Piste sions See (st eo wor) t Sum 5 4 a : Pe tho : ae Quest: if ( n= = Som) 2 " porinah CT ARMSTRONG: NO"); eet ae ( "NOT ARMS TROND No") 3 geen QO) 7 Woride oF porogram do chetk Whether 20: us is PALINOROME °F oot H include Roymre, ovder = Ovid HE Include eA tay a ae vorc man C ) g ae URS Sa ay Hi uri Oy Scon4 C fds faa: ara fer (fen; leo} jsifo) & vie 1710; Sum = (Suro €10) +4 ie i fio is if (Sum == hn) uae Rio ie Pod ny print ( No is Palinebtory")), One Printh C* Newt's net Patindione any A: getent )) 2 - hoe Wore #0 print +he e _ potogram tac 1 my 7 6 UT blo 1 Lio in Juyense 8a > TE in clvete include Ktorvohs VOrel mos, @ . int ny , Sum = 05 Scand C hel", £ny fon (r= 10; fogs j>j-2) Sum = (Sum th) * NESTED Loops~ y NJ Sted loops au those Loop in Which bone oop ix CRE Coded FMSicly anothn Lwop: > Genecatty Nesteot Program, . loops We Wud Patton eer Guess WoO Program in C +0 gap erede gmon Potttesan + > Fe Inclode +e include Void main ©) a Ind Kooniah > 1: 7d 5 at Ciery iguy itt) ata z Foot (gery J£35 511) 2 Printh (" wortp")} = 4 tho)) 3 Ques Woarte cq ptogyom in Cto gintrode the given Pp n: — st include CStdioh> include < Conio: h> a Ss vord main 0) eee t eer hay ooy * int ty 4) ; for Gey 855 yt) See aes for Gey F415 G1 pig Cry 4 geteh C); a i: Qe bide a program In c +0 genecede the — + include HH ineclode < Conioh> Vora main ¢ ) Mt Ty 4s a re Ly JSS, a) fen Cx a 4)5 al 23 jee C)) Que'\- White w program inc +o generate ths Potten — tH inclode HAL /nclude vord main ( ) é Int go fer (iz iss, str) [eo 55 OB 5 gre Cay; 3 a Jeteh ©); JU yy « » * » * yoy x” ’ Boe White & pstogram in ¢ 40 Gennrede TAK give, . Po > HE include Sey HH inetude as | Void main ¢ ) . ins 4) irgo[> 12 13 | Peach cota ; Tope TeCisa, ges y cer) iaslt (2 4 2 cel t fo) aly fe Cats Isis gt) d Peete Chk 5); 3 Ch cy ait Ques’ Wbsite « Pxogram inc to generate th Patter — HF inclode ay le le lx HL include vow y void main ( ) Yow ye ct : . eo» T int 1, 43 fer (iz Uy iss, str) Ce ea) poe Clays 4 getth ©), = p * goss Poogr am +o ganenecte gnen pablo. > te inchocte ah Include void main () f ‘ nt 4,45 vis for (deg; dois ict) : E ° | te(gets gsisgt) Lu Printh C8 ha, Gg) 5 % yteh CD; 4 doa Raegram +o gunowse given paktorn. — tt include 4 te include void main ©) =f S 4 2 ind Jy 45 0 foy (isa; x c65 it) a | 2 forldea dst get) o prinadp Cea 3) 3 & gech C)) 3 os ey patton, Ques! Program te gre é ~? FE inetude ch Mclode H include < Conio. AD void main ( ) : bd $ eet [re ay gale teas for (iss) iss; f+) / — é bea) feilget jesus jit) g . 4 Po 3 fey Ck25 Kea; Ktt ) ei Printh CS x "sy prsth C\n *); 4 Geten ¢ )} om USE of by and continue Stottrmungy 9 SC 0 tak \ OA Dienk= ) ae base selon “Lot ———* ee Conclton, TASH the Loop within it bthen break Statement tht S IS & COUN Ferret "544 loop tne pxogram condos Com % oy, oh the loop fore celly or ABN cepey &9 > Of break Stodiment. 7 Write aw Progen, | =>.t MUvede Continue statement _ Unlike bre aks Stodemer she continue Statement ore dwins the program control back to the loop: > THE Continue Statemtnd i's also Used insicle tthe Loop and Within the if ConcGtion. eg? of Continue S+tatemen +: te include tHinclode « Stelio.hd At inctute H jnctude > The do white Loop %s Wed +o LXE Cote the Yroup oF stodemunt uprated ty . > The Syntax of clo -while loop is gevens clo é Group o Stoatemaends} Uthite stoop” ) > Floes Chant of alo White Loop i's given as ote Difference blu whit £ do Whi Loop + Lhily Loop Qo errils Coop % ThE hits Loop Tr cle. white oop tH ConcitHon Is evalvated | execution of S+tedement> Pisst and +hen tates place first ond execerton of Statemends Condition i evatuek pedkes Place : q J loop w To While loop , dy i, # Der ele: eerie f ecection of stoderunt not mandatory thes * y with tate place fox ERCCUHION of Stodemend oF Stast- one tins will Fake place, => NOTE? , ¢ d , H+ Buea Ro Nam +o Chede on Armstrong no Using do while loop. — # include < Stclioh> Hinclude < contoh> void maint ) é [rt WA, 4,4, Sums Oo; Scans CC" hb", boy rou clo re if105 Sum 2 Crayne) ¢ Sun, Te (Ploy, 4 COAL @l=0)> If (ra Sum ) C ) PY” Armstrong No") 4 f Clye é PPOth ( Y Not a nse Mo?) 4 geten © ys - HH EUNCTIONS+ FF Include HE Inclocte < Conjohys 7 “eheeetverel @dd ( H+ "prototype (ot: ein) “bro VO / ol mon( ) as Gnrg mnt a, bt Stank ("hd ral ", fa, tb)! Feattise, a el a Ca a) fen Pe = idl Lue prov’ Cate by value, ce rman £) A tal add Crnte riIntd) — fon ctron olefins tion m+ery Curhosr ia chon @2 etoile lined f J eat) aPrnth nay eps ae Cotectovu 2¢_Fonchons > A function is a block of Code Which execu +o perform a Speci fic task. > The aclvantege of tet'nre mathiple Sunctrons ( Usest cl €rncet Functions) mat program matey, the Pregramming cary to Understand. => Type of fonctions +t Theu wu two Categories © Library cliFined functions + The olfinitron of this Ffuncdron is altura by precend in thy C fan voge . egy man) , TAH, — SCamp OI, printh (> 4 © Usey ol Frineel fonctions + The cefsnitron of taet These function 1S crcated by the LUeH. Crt could be any hee except tb weoiay fonctHon. OF? cdi () XYZ), ext ) et. > Components of function = There aie 3 components of a fonction + O fonction pototo ty pet > Function prototype Is clear ocetsrols ths main functon to give an rchea of Hating OAM chidintd function , > The Syntar ton ction prototype rs given as Fo! lows — clata type f” nome CD. © go Vvotd add ( ) ae ON © Fonctron calling 2 9En Functor Calling ~ wh T+ Ong Ffenction cally Fanother functron +o POR, Some task. 7 Tiss Lyn ta x of functron calling rs given or Kt, ” M ft Dame Cearameters) Q fG- acl Cab)) © Fone ton af nition + This Compontrt Conteun, of cCocte +o prtform Some fark: a bloc The Syntax of Function ca finiHon is given ws n Follows Aepetre Snes nga vic aaa te ring Block of techs eS ze: % ezct+el Print Chl) J GHEY, Ques Write a Petogreun to C+o Swap thr valves of +0 vaxiable using a thisth vanioblu with Cau by volue +tchWique — > cH inctoude AH tnclode void mein ©) void men ( ) @ Int mh YS Que WHite a progam in C to Calcrtate factor ic of ano. Using Call by valve method, —-» include He include Void factorial C ey void man ( int 9,4, Sole 45 Scanb (wheal ny, factorial (ni 4, Sot), gen’ yy % void factwuet (ingen )) inti, Int sol) g for (4-4; jkny st) é Sls Sol xs; 4 Printh(™ Tick” Soy): z Choeg! » coo © AO theete am fn WWoeiye a porogy es WI Oday homer tuing J Vali che Mebuce “e stection he Ht imelude Vorel aimetvong ¢ J latory MDiol main ¢) C Mma act Stanb Cra ", £n)5 OOM Soro Cr )5 Jere ¢ J % Void cumstrong C int m1) Ine a, wy, Sum = 05 Foy ( (eo lee, te 1 iio) Rie eros Sums Ot x) 4 Sumy 4 it (sume = ww ct Prin th Ce Prstrong No")} % clye 2 | “Not Are strong Alo"), it ifros Ques’ Waite a program Inc Ww Genmate a —— Libonaced Senies of 20 numbeus an o print ts wing calling by valve- — > 4b inclucte beats th include < Conion> vole Fibonacci C ) vold main ©) : frase HOH Scon+ ("Pd Fd" da, tb); fibonace) Carb); grea yy 3 Voice Freonace; Cink q, inth) 2 Int su, C, Sums Oo; for (i=4 5 ix 20: i474) z int C3 C= ath, Qa=b) -be Cs Sum: (Sum ac)} 4 printh ("AY O)5 % = fe. > CPrp,, “a Cathey vatve (Pesiit) | Catt by Rea man ¢ ) mon ( ) $ Sa OSH] fae] ST fst ew 4b “~ oeeey % PLO vay, > 3 OHm ( ) win C ee SS ; atin a e prt lOO a ay eine Zod Somer 0dr} [zor] [ae] ga ee ar) a 4 iain desire einie sie he Cwovlts on WorkKA 8n iginad tp 89 photy copy” e py) — Pointe; variable Stoves Adcbiess of vwriak > Ine *y — Stores, enty int vasciable > Chan * yY —> Stores cr chan voodahit, > float * Y — Stoves only Float variable: > clouble * y —> Stores ently clouble voor able Hh Col) by wefvrence + 9 Th cat! by srefurence OW fonctron Pomes tht addres of varjagl + Gnother functions: > The fonctions that CALE i Calteol the bobbing : ; CohILE The Second function 'S Called the ‘cated > Becawte the addres of vartables 4. parseol #0 another fonction, the chan Mack by fra conte functron On ths acleluers of vourables crcl abet the valu of variable present in calling fonction. Gues = Wutite eo Pero gram Pac to Stwuays two Numbers tuieg Cat by Ute Bence. — > + Include th Include woid Stomp CIB void (ins Fain tev NY brine void mein ( ) z Int % 6S Stang ("Lodho", La, to)! — Sends ab b with adduerr. Swap a4 5 =H paxamettn (Catt by veference). Gtith Ce % void Swap (int *a, jnt™ b} int oy a » volue at adclue, Stoud in b. ee x b; tb = * a) Bq 2 C5 pooh Ld fa" * a fal) ichaie laity aapnden Vaiabic+ 4 Quer Wout ce pregrom in of a no. UA cau by wefrence. to Sind the factorial =H Retin Stetemand > Void J’ name = The f? will not retin any value. Dnt eS name = on retin an tndegen valu > Hour f’ names tpt eet — Me Chon vedi n Cloubie volute > Chon f° nome > doubb £” nome > im us y Eq? ( ) inst mul ©) arnain ©) man | ) a - _ } \, ti add ©) int 2 Int ey “| Lz acd ()), es divs *Sub ©) eh ; \ ~ehurin ©) Genet) rector #0 int add) i tet Oe tO pay O) ink : sa . i stoyezrnod \) ge see, az mod) Ger dene| [at ordtuin Y) yetuutn d) P int mod) by int SUbC) & t . Intars, b> 6) \nt 1, ines me mult CO)! Cz atby Hu mS . wd" . FRIORIES PS pande('7", 4 orehuoin ©} 5 Note+ [us we We voice main C dg then we hoe ‘snot fo One rerun O- Buk we ure int, Chand Soon, flows maint) fh te necemany fo Ut ¥CtWwIN "_” fomitiing J, Important points +0 wrt meron stedemand S The netwoin ‘ododtemauncd used Urhin the “tolling § caus the Caled £°" to petform Sora task anol the called ff” har to vrettuinecl the valtu bac to Caltiag £” >To Use The vretuin statements, Aotatype of f™ must be Changed - DOL try J? haw void dose ype> pthan ne valu wilt be ne dunned - the dS” has int clata type inttgen value 6s /'y be 7 " u Choy Chan value u . ca « flont 0 Ffook 2 ' » deubte «double» 4 Qoes:- Lbiite a program In C to adel Hv0 no. Maing cS” and alro yestn th vi , =. Pe inctude cstetro Wd #E include Int add ()! int mmas'n © ) & nt & 2 Asada ( )! . ea Hee printf oso can be vans. ote tin 9D becaue MF Prine ft Det oy A necerany & 4 (n+ adal ) in main ©). int Q>S ) b= 6; rat Cy cer arbhy Pootge CO“ 4a" © return C 4 J y

You might also like