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

C Programming Notes Part 4

c programming notes mechanical engineering semester 1 part 4

Uploaded by

Farhan Masud
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)
5 views

C Programming Notes Part 4

c programming notes mechanical engineering semester 1 part 4

Uploaded by

Farhan Masud
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/ 16
“main () chat namel J = “program” 5 while Cname Li]4= ‘\o') — betavse all strings have a null Wye haracte O at the end. If printeC'%e"namel id); itty i jain o) {chav name Tt I=“ program”; char *p5 PS a Tame|-s base address. baname, — Leemel while C*¥p!=‘\o") schan type van (no address) PAGE CHa NP) “emty mention base | Pts address for chan | 3 Natiable pointers. @ becavse we are pointing the Memony address [The memony addness 1S ‘shifting to the sight llana p points the value lat that memony addvess | each +me. |) main ©) string print? ("% 5" name); main ( ) [char namel J; scanf C" %8", & name ); print C'%", name) Lcharnamel I=" program” ; fon string, the sean? operator will constantly p Input Chanacters until “enter” is pressed, ogets (wanks os scant subshtute) Ly puts (mks as printf subshtute) sent on element in ay f witite a phegham in c I anteay. Ft indude int main C) Lint afacl.n,i, pos, sah print( C" Enter the nov of elements in the atnay: seanf (°24", BPD} printf (" Enter the Value of each element: \n)5 for Cis 0; init) % scant (°Z4") & atid); k prints ("0") fprins? ("The elements ave: An")5 fos Cizo5 iS 44) y printe CUZ NE “atid, } printf C Enler the position where You wil) insenk an element: \n ")) ccant ('7%8", BROS); printf C’ Enter the value: \n")5 secant (124%, Bvt; for for G nj iyeoyin-) Lp for (ie nya 1X03 i--) fox (ie nas >= pesnad 5 1-~) I, eee atideoli-353 let is a[posn =] =val > for Ci=Oy ic=ns ind g printf ("% a \esatids 3 3 x eo Write an element nc fo teverse an || & aray. || #inctude meains i is Pointing on a chanacteh type variable, chan styl 2 Heng? chan sty Cio] ; chan %» Hettos chan kq », 425; j ster = shel) X a Hinclude : Pinchade Cofd lib-hD actual dtegoment 7 main () in) main fonch'on - int So email at genint int lend 5 in osery definsd foncho chat ova Y=“ cycle"; ark | (NT = x strien Cactend> PRIMEE C" The length is %d" ent)3 | 3 RstttenCitent Merete For string, address opera tp | XStrelen (#p) “R) not needed TURP = stien (ara), } dtwhay declared int main€ ) string assigned chan ana T Je" Bamboo bed", int jents (2 4ehual on gument lent = x stylen( ara); PrIDLEC'\9 sheings 7s and length =%24 ara, tent)! [| | xotnten Cehar * 5) Vlength 445 Sts 3 lt int length =0 5 : turn Clength) 5 white (4 *5=\0) 4 int seottrco py G8) (char *8) vinifaitig int by : {tox white Cs 1-0") Lis an emply ‘aivkay oF ple «string. | xsttecepy (chan #E, chads) change With cat) by _ permanent change. { white (*s!=0) address - per Lets ts, change with cat! by function: oti change is localised- Ly Mere} dbz; t LoJ=slol tfoJ=s Hconslant Ssource is fixed > the steing wit not change then. chan ®p= Hello’; constantcharr *q 5 kg eeu): ape oM's * : *q<'Bye’ string is fixed, not pointer. 3 | chan tager P30] = “teito”5 Il cineat (source, targeb); | Prinl# C" faxgeh ghuing © 7-8") seumtanget 3 printt ("source steing = %s", tare souh 5 | Witite a Catenation. int mann C) Lchan souneel J=" Fox *5 Progam jn C vsing a vsendefined Function hat wit do the same Function 03, string (a7 69/19 int main © ) Lo schar string sil ]<" Jerry”s char string 212" Ferry’ int i,3,k3 je stremp Coting1, “Jeary” 5 d= stremp (string 1, string ads k = stremp( string 1, “ Jerry bey D5 printf (S#\n 4d %S wa aks J define FOUND J . 4 define =symbolic constant dedefine NOT FOUND O * maint) Speherint JL char sist Le Tte] ={“Akshany”, “Ponny > “Roman”, “omimive s, * Gopal”, “pajath", S [iJ[oJ > base addizess ‘ a : Cfiirst letter ony) S | int i,Flag, a; char yourname [10]; scant ("7% Ry ounname); _ Flag = Nor Food; | for (iz os i<=8y i +4) { asstremp(& list CATO) younname) ; if (a==0) Print f C” weteome.”); flag= = Founn, break, j } 2 if (flag == nworFounp) & printf (" Sotary.")5 5 Discuss about oteing comparison. white down a program to chow the application of string companison 1 = : char *tist0 J={ | This can be done with pointers i main ( ) (ENET TS Tesnan ¥ L chan namest JL Jt" Robin's Parag"; * Raman” " srinivas’, } ant id char bt; Printf C"\nze%s", Rnomel2ifols & names t®Jfo]); for Ciz05 idsay ite) Lt = namesattils names Caq[iJ = names (3Jti] 5 names C3]CiT=t, F % print eC" 75°75", & names taWoJ& names CaILel); 3 maine ) " Parag": “Roman” “ sranivas “5, * char “temp 5 Prine C“ \n vs 78", names 27, namesE3I)5 Femp = nameslads names E2]= names 375 Names T31 = temp, printf ("Xs %e%) nameL2I, name t3])3 i Streueturce Svairiable af a fimeyuse many datatypes > declame “cha in tegen sete types of variables at bnce main C ) 1 {chav name C935 Float price L5)5 sre pages int papers [ 31,3), for (j= 0; i¢= as ire) Lscanf (Le Zp 4a", & hameLiT, &priceLil, & paper Ci] )5;} maint) { siruct ook 1 Q0/ Jo 12019 main ©) Ne gate hewiy |] { chav name ; float price; int pages; Struct book bysbesbs5} of |: sem ta mid Seank ("Ze uF ZI", Ebi name, Rbj price & bipages), | scant ("Ze LF ZA", Rbdname, &b2 price, Rbrpages); _ Sank ("ZACZF ZA", Rbaname, RbIprice, & pSpages); fei printf ("Ze ZfZd5 biname, bipages, bi pages); Print C"ZE ZF Za", ba-name, br price, ba pages)s printf ("ZC ZF Za", baname, b3 price, b3 pages); retirn 0; | 3 values, | ARRay: Many variables of some data type | in one vertiabi Ghructite: ts handle different datu types. Why Is strwetune impon font C-peegtammi ng, ~> point fotrm 5 definition —> example (MvsT) | Te types of constants : | > numerricar constant > string constant: “Operators: Arithmatic operator, assignmend operatos ett Heiss fox, if else,do while, else if, go to study I+ go to se examples | | + continue statement s Flow chart sawteay (1p, 20,38) —> how they aire sized in the mMemery, || ~Dvenite = insert + find the min. element of || | «delete an atikay | annay | + add - find the |posn of min. element fre Verse || >write a progam to fink odd =matices. > pyteamid preegicam Ly ohudy the series of sin, €05, e™ ete. is Pyramid | Preegtam * AND > ee 7 ‘ a a3 Se aig eS TF “ 23

You might also like