[go: up one dir, main page]

0% found this document useful (0 votes)
23 views11 pages

Functions in C ?

Function
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)
23 views11 pages

Functions in C ?

Function
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/ 11
“fonctions a = “Tein block whexe He psogaam code i wattten . S - Fonction i a eet of inst suction placed togethes to pester P apecye tank ; 3: building blocks of C- psoy eam tbo fonetion i =. Beneyito g qunctions 1) Divide and conquex a) Monageable fa development: b) Constduct a rsa }som mail. pieces 08 componente - a) Doptwaxe xevaabilt : 0) Dae 2xitin jpnction oA ee blocks qos new pee $ b) Abstxaction : hide Teexnok dethile ( Libsary qynetions ) - : Modulaxity, : * Treack fenetion® = Chow a2 types Of gonetions ) Predefined fonctions | EXbwoxy Jonctions 2) Unes Aetined Fpretions ; * LSheneves these 1 texm cated fon chon fa C= Raingbage we need to think S points 1 Fonction declasation (Fonction psctotype) 2 Fonction cadh 3 Fonstion definition . Pegctekines Upex defined “Fonction declaxction Heades flee os I Sun oe adex le, oe coll a Gus Psoysam OL¥ Pxoguam ‘unction definition Ribsary below main ( Anowhes- oO. * How to declose a fonction (ox) Aymtax. of, eeclosia & qonction => Retoanty pe }oneifonname (axqumentis) ; = J * Depends on the axguments and yetvan type , We Can asian w the fonctions in 4 methods - Y 1) Void frame Caxguments) 5 Ex = Uvid def Cint , chas) ; + def isa fonction which takes dL Oxauments ‘integes and chaxactes and xetuuns mesnae : 2) Usid frame (usid) 5 Ex Void abe (ucidh) ; A + abo t& a Znction which takes netting and xetusns nothing and pesieem bKome task - 3) xetuwndy pe Yname Cusid); Ex:- into mno (usid) ; * mmo 16 0 jenetion ushich takes trical and setusns sated 4) xetuantype {name Caxgumentis) : Anis wee RES Ex: int por (int, int); WEN Oo AeBUMeE tS + Jom is the nome Of fonction which takes J integex os an Siemens anc xerowis an integers : * Seaign & fonction fos Psinting the nombex into bi eo bi erm + . => sk include < etdto.h > 5 ear el A Voi pint - binasy Cit); || 4" psctotype ae 1s Voik main C) { int nom j Patty ("entes the nombes .-\") 5 seas ae torts paint — binasy (nom); > ‘ com ig paint —binaxy (int n) int Pow 5 dpe (pos? 315 ponaso: poe--) |/ a. cbon vos perry (728 ", 1 >> powt 1) j o% v Paivrtt Cin") 5 £ dekattion 5 he * vohile Pp poneing the motion hats WT os possiny +hoseYaxe called ab chinks oi ee yas ane ‘ Qsapment> - 0 os “Oe * Ut ushot we Ase Catching +hose actu Ee ae ‘9 ctuol Gguments axe cated, % Actuol. axquments name and poemok xqumert name con be Lame (0%) Gaonnct be AameE - Tip eee => ab include Cs 1 ant count — set— HA Cint) ; ieee yoid main O ae Ae nora Tene nom. 0 5 psintg © Entes the nombex - -\ni") 5 wy int secant (~ Aad" nm) 5 int — binaxy (aem); 6 = count- set _bits (nom); printk ("C= eA In" S)i “3 * Derign a onotion to count how many bits axe bet ina geen 2 = } Gnt count - set_bits Cint nn) Sent pods count 5 dps (pos=0 5 C=O; Pow<=S! 5 poot+) ig (n>> poot 2) C++ 5 ‘etusn © 5 if * Resign a Fonction te check the ae nombex 1d paime ox not . Dp petme xetuxn | else setoan => 4b include Sint 4 ime = check, (int) 5 usid main 0) thee or fnsi5 ie prints C Entes 4he nombes .-. |"); : cong (4d, d nom )3 % = peime- check (num) 5 yo ik (221) panty (Yen tt te peime ... In") 5 else pet) CN % te not a psime eta); Z + z Ant psime — check (int nom) oe Cis Q5 Perum 5 te) Lag (nuom7%i == 0) beeak 5 i if (norm ==) wetoxrn Lj ee fr % Cah by value = While callling the tection Tf we pass uatue that method Us called as colt byualue . * Colf by Setexence - urhile calling -the fonction Tf we poss addxebs of a variable fat meted 6 calteck os calticy sejesencer aF Inctude < Aintio.n > Noth colt by votur (int); void cokt by wef Ciert *) 5 uotch main C7 int nom = 10 5 psintk ("In main nom = 74 & nom = ¢ pin” norm panos) 5 Hl cakhloy value (num) ; paints (“tra main nom = ia \n“, nord) 5 void. Calltlby value C tnt nom); “FERRE CSndtnetion noms 2. Erumer pln ram Uoids coll by xex Cint *p) RP= LO 3 Eh be Void Swap (int F int*); void main C) a fat mL Wa 5 Sint; CvEntes the ni and na ln"); secon, (*4R AR" Ent Ena); Painty (Besse Swap ni= 7k NV= Kd \y", 1 NZ); pwap (€ni t eaten a ee 5 eat + 5 t= ¥p ; 4 Foornal, aggomertt connect be = *P | =*oq =: ON ABSay YPC even -thovgn pcre 2 we we catch ustth an asday | waza AE ie teetet ab porte oP ype - * Design a Junetion to ysire the elements of dexivect integes OES . => ee aes ptdio hn > void pet’ (conet Wt ™ tint ) 5 void main C) Tent Q£5) = {10,2030 410 ,So}ele 5 ele = Aigecy Ca) | Sige os (atol); paint (a ele) > qoete pout C const int *p , mt ele) Ant 15 me C%e0 ; 1 sr include catdioh> Void paint Coonat int * int); void Bubble soxt (int *, tnt) ; - void main C) 2g int als] = { 10,200, 30,400, 50} ; ele = Sige of (a) / stgeoh (aol) ; paint Ca ,ete) 5 Bubble _ ost (fnt*a , int ele) - “sg E tant tag tj fos (i=0 5 i alge) see aby; alg) =atg+1] ; alg+iy at; Pee TN eee oe @ « pp PPPs 2 * Heston a fonetion f3 parting _ Btsing, ery tsing ee ~~ hie Sevexse patiing sevexse’ in a eh gle victors = aFinciudke Voth my= psint (chax *) ; ‘int my—stslen (chaw*) eS cha *rny— stachs Cohas *, chas) ; ued roy— Atxups Cchax * ) ; voi my - Stexey (choy *) ; Void. my_ Stsepy (const chax * Chay *) ; cietdeenbieney 1 : chas AT 50] , ATS0] ,ch ; Paints ("Entes the dotting f\")5 for % Cn)" 6)5 imt} (“Entex chas r\n")5 Pea 7G", on); my — print (5) 5 int R= my ~ stzlen Cs) ; paintk Ckength = 7Rln", &)5 Chas*p = my- stuchy (,ch); t Cp2=0) pairtk (“chow not psesent rn") 5 pdddddddddddddd oexint Cchaox present @ p Location |”, p) 5 my - paint (2) ; my — stsups (4)5 my - paint (6) 5 my — paint Cb) 5 my — Stsseu (&) j my — psint (6) 5 eng—patnt (A) 5 my = atecpy (Ai) 5 my — peire Ch) 5 york mis paint Cchas *p) fae 13 psinth Cte in", p) 5 qoe Giro 3 ptt ; 3 +) paint (+ Zo", pCII); (08) ushite ( *p) printh (4 0", * per) 5 pint Cn) 5 Yat my- st8len (chax *p) L int T=0 ; Bs G=0 5 plid; tH); setoan % Fi (es) ushite (*p) es T++ 5 *etvsn |; chax * roy Biechs (chax *p , chas ch) int t ; Aps(i= 05 pera ; Sat) - t i} (elit ==ch) setusn pri 5 setuan 0 5 york Rc atsups Cchaa*p) { int { 5 qvs (t= 04 pCt ‘15 i++) if (pltds='a' 4¢ pli] <='z!) plil= pGl-32 ; FSSP PSTN UN PIN SSNS SSRRERE Renae, 2 Noid my - btssev (chaos *p) S tyeig 5 chos +, *q 5 t 5 qe Ps foe i= 0; pls i++) wie (#4) qos (iz i-1 ge05 F<) sqrt at—-) qrt 5 Saas Le plid; ushile ( p wis my-stscpy (const chax™ chax™); my—steopy (ot, 6+! void main C) { chax Sfio] ; paint} ("Entex the 4\n"); boar C768, 55 3 paint C'Bejpse © = /41n" 6); my—Atecpy (+1 , 6) peintd (“Aktes = %6\n" 4); + % Design a dunction 40 severoe a Nete.:- pose ‘Atasting addkess and. ending addxebA And xeVeuse =the dlata in between hove tuso Location ¥ stinclode < stctio.h > oid. my - Atssev-1 (chas™ chax™) ; Void main () t Choy SC30) ; paintk Centers \n") 5 swoon’ ("75",£); puinty (“Beppse 6 = 74\n",6)5 my- stexeu_1 (4+3 67); Panty CAgtes b= 4e\n 8); void myaptesey— L (chax *p ichox*9 ) { Chow ch ; while (P while Cp= my_stschs (6, ch )) > 1 [e[m] ole [afotfe ]o]vs) 2 my stxopy Cpr. p) i ele [afotla [v0] =) } “~D % WAP to severe wood by wos Wo biq Aentence by oats = my - btachs O ymy- staseu_1 () , my—ptexeu O >) 2 ~ ~~ > > = > DV

You might also like