0% found this document useful (0 votes)
3 views56 pages

C Unit 1

The document provides an overview of the C programming language, including its history, basic data types, and key features such as portability and code reusability. It discusses the structure of a C program, including the main function, variable declarations, and the execution flow. Additionally, it covers operators, expressions, and the importance of flowcharts in programming logic.
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)
3 views56 pages

C Unit 1

The document provides an overview of the C programming language, including its history, basic data types, and key features such as portability and code reusability. It discusses the structure of a C program, including the main function, variable declarations, and the execution flow. Additionally, it covers operators, expressions, and the importance of flowcharts in programming logic.
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
= Baris # \ntrod Qn to |} __1) Te nova pecan ee einen. 1s — Upp wt A ko a a. to Digs 9 St exs mbols : topesl, 1, oh ey 20, 0 Bsa 0 ee + White spaces rae Horizonted be 2 Neale Cl > Carriage. refurn 2 eetadile Op) T ei ane sequences am't be tuned. direct! non printable) 2 \n_ (newline? 2 Mt (Morizontal tab 2 \\ (backslash) => ima) Q\UOrE STN eee eae 2 \v arriaae a > \a (ue audilale 10 2 \b (Backspace) = move the 4 pont oe > \ WINE RUT EG bas Se > \0e lasers) Sil 2) he s i ap ote 2 eee ey 7 EE > 0 ) identi eke * The name udeds e hal aT Sus characker musk be eit qn alphabek or an nd score oh | Fee + iL can'k be on the ame. “4 ; vert ee + C language is ¢ fiat , a ,_—Idenkifier in uppercase and. Aowir cade art cow Honk sherk. wnusigned. fer continue signed. hata. goto sizeof volatile do if stole while | + dofinss_whak bupe of value o variable" store, | Inc, data type i broadly classified ax __2 Basic data types = Derived data bypes J 2 user dafined dake Aypes | Basie data types 2 Inkeger| Character | Float | Double. Void. ln | + Cina middle Jousl & general purpore eseind i beceain g ories by Denuis Ritchie for the Unin 0S in early 4370 og. 5 , vuritten toy ke Thompson | Hiskery sf G a mle i +4960 ALGOL International Group | +-4967_BerL __Marbin Richards —|| + 1979 8 ___Ken Thompson, jag ¢ Denis ait | 4978 KAR Kernighan and Ritchie +1990 _ANst]1s0]¢_1S0_eonamaitee r. (i | 5 8) |Advonkages ef C_pregran, —___ + highly” portable ~ can yun on. difterenf, L : platforms | + supports a wide range of dada types IL + promobes code reusability ~ through Sunchion | and Woravies duntlopmunt. 9) naa C_ program. “no cont} of tmuspace. inc. ; group functions ¢+ variables under a named — scape ol: mi ki? 1), Apiabions of C os ie [fe Oper aking syskem pe ih 2 widely ured im dowelopmaen of cca due to Ws effletency and obiliby to directly iwheracl Tae or Unix, Limnos Fernild "re primarily wo Salbbew i 0s ia) a Inter preters | _> Gey show. interpreter for Rylan. —_ + Assemblers 2 Assemblers commer anenbly language ide |? Somneoumamblers # titer tole av elle acs olz= Feakusces of +simple — tah GRR = aed fost __+ structured. ee [i Herkeniue paumovis oa : | * MACMANE. NAL ALK 9 pe ONL ’ How does C programming Aanginage * Execubiow of dar _C sean icine lower ee * CXLOKAR Tink DrOgraimM preproceuiing ompili g the program hinkeng the program wit. Sunchions From tae C_Lilorarey ve euuting the prog car eating a program —> Source code Other _p Linker - Funckion. ma obiect. 4 Uibrauries cody Kecurohle biect CoaL stdioh — want he impuk/ oukpub : bh» ol Ic. Basic. “program. ons F Guide “ie | #include< stdio-h? = Dukpa Hello Wo oe 2 ae hh | pend Hello a _| peluun 0; i Explaiaabion — a eS ar a aa | stdiorh? — header he = thi fines Ahem veiabiea lp uleleo leer and a variely 6} inpuf and __ oukpub functions -rnain) = main function rain function +1 = opening curly brace = _indicates Hoe stort of a function Pes ofz4 vinkO — wed-to duplay ala ce [eae 5 = mau Mt end. of a stakemmnt syehun 0 — this command shou te exit nee aks oy a AL jou ; 1 z ee « 4 = closing curly brace ——_|__ = indicalis the end of a. function eae LS mpettank poi : — > A\Uusa Me {) Witt Wy YL & Not QU ON V, en © @ tu f several Ee explicitiy ingenk bo exit an Come + main Junction b 2 it's necessary to we ont main unchion seckiow. in_euery C program. | __2 This section contains. Luo parts, ____didavation and executable part. ___® The decdlarakion A tots | | the vartales that ‘te ured in || exeruika ble: -po ie | bw _ tne opening & cloting braca, | | anh executonle port mutt end wuitle | 3 5) 2 Thue uso pull nauk be varitken in. gl |» Fach stotemomb im the decl 2 The execution | f the progroun storks ning bras aut ends ob _] ad opeini 44) ibs called PSEUDO CODE! . properbies — > ne > Nnite nul 2 dolni > eflectivenen ? eal) to vorite 2 Abe logic ——2algusitims Yor big problems can be myttten with modeiate efforts | 1 pat losis Reads & number a. b 2 Fo = -duadvantagel 2 diel Lo debug _? difficult bo show branching + lcoping 2 Jumping Cgoto) makes it hard bo tvace. | Some problems. ee ee sEg= Al Algorithm for fi filing sce ra numbers is ieee * Stork. ) | Flowchart pe sa a Q ackivities bo be prov rocested. ___for_getiug desired oukpul from a. asqinMnpubs. eit oS katte a Wanda symbolt to represenk 4! ac fab peietnete a iw | + symbols 've linked together usit ave no + Pocat symbols cielaabeaees | Fe I erminal = start] sko _painllt 2 lll ~ ll i ed tb ee Premed itiee ‘eee | : e performed con manag is __® Decision box <> — decision operations | Una dokermaine Which of Ye alkernalive. paths 4a _ be followed. L > Connector O - ured to connect E different parts of Flowchart, __—_| 2 Flow 42? = jis 2 symbols _# also re ae of execuften. + ady es = easy +0 Ayo 2 easy to understand tne logic ii 2 easy to show branching 4 looping 2 easy to identify mistakes by non | technical person. a flowchart ‘th flow 4 How emer, aus I mshi Cone | l= Poi ae tors re fea lokcotitactinaeen Lt, fa iabe oe a || £4 | fg from ene page to another page. a psec foto ps | i). sizeo} 0 operator ts _| + Eq > #in clude -lnkeget Sy! ey =ve , tae both) (rere, +ve) chert Fthoek ie Song Long Bytes > sInbeger [2 or 4] RT «Integer [- A256 80 Ls 2a) ee sshork cigned inbeger [-32,768 to 32,1611 2,44, 14, 25,648 rong _signad. bwLeger [= $0 2,44, 74,83, 641) signed ink >%d ov ZL unsigned ink > Zu cher “antiqued. inbeqer “wor 669391 + Long unsigned Integer {0 40 4, 29,44, 67,. 295.) dai» as Setinaetseartaldo, |” 4 Formal specifiers = al See | + Inkeger Cyd Soy Sia eee gees] —+-sherk signed inkegeiiyind | ——__7——— ong sig BiB ee | YA oa cdving = 4 "Tat oleae ia i Sieraaaie a th 2 dect 1 , 2 type modi ies + float, double, Long a clowble 2 Byes > Range 2 eWay mec tole Ao gue 2 double:— [1 Klo-°8 bo 11X10? > long double :— 8: WACK Gace Cy {fox ip 4822 | signed char = yA uusiqued ear = Zu OD Jom | » cyntax ae . 4 | > floak L float variable; ] : 2 double (double variable; ] Toe Charackeve 1 nsepr iia eatery 2 stores single char =a 2 dong doublet dong. double variable; 2 gee (ake eae ae eet! MARS, quam 2 rounge = 0 to 255 (umigned chat) | tonge = 128 bo WI Csigned. char) __ #include & ‘ekdin. i a — ink main signed, char chr; chy = 1285 = e ai y chr); velurn OF 4 Sel: Eg a+ signed char x= 120; i Boy: 286 = 130 1807427 9» 130-256 = -\26 + Signed char x= 129 een -l29 4286 = 127 bd Sh) Peed Less) erie i 2 eS = D7. 256 = 955 9) Constod e | | any ewkthy whore walar can't be chang | eee of, tar _progrant . oe Inkeger constants = Character com tants ___= Floating peink numbert con = Shiv, constants + \nkeger comttonts = whe the tomtant comkaint only withouk ony. decimal par SNE Gi Bir Oe ite kes Ir —s\ Ee Aman Ree a Saaete, a = constants the conbaind mumber will, dcctimal points epee a ere cet | * Characker comstonds oe ~combankt enclored in cingle quoter Ea fet ese ies erento * String Constants ~ seb of zero or more characters enclored in_dowble quotes = ga Ti ete s Variables nee RE DE IE GEE EE GE EE Ge 1+ dohatype variable = value j | when comma is wed, veaulh it last expression value, oO |= L 21) Expremions ear walid combination of operands gud. operators thak produtes a rok, mm operand — upon which pw abion | | i perfor iil iistsigbe. | opaater > who performs the operation Lupe — ist Pang fae a => Cowtank expremions = Dad - eis i fsivmlleatbebi oud = ven | 2 Ralati i fae Srelatiow! 2 bikiuite + Mitlanutic operalors i II Lid — I = binary operators ure for basic math of 5 —_|-—-2 diteription “_ permtors dueription eu BE re eee? i: — hb) See _ swhtracHon ihe Lee ae ip\i tation. Orb f Ld) vAuaiion l. e) %) modulo division ay = | ‘i i | wor own} wh ink operands, + I > Unaiy_operators ———______ | operaed ona single operand, __ b 2 deberipbt on } duoription enamnple a) + wary plus ay, bi (unary minus =o e) 4 incremenk $40) att ales decremmonk ge <1 Logical NOT Va 4 Adve. La ie pol cm ® h) sized? ey in bytes size of (a) 2440 incremenls a byt and thon ured le volt as the value of the exprenion. This is Fnown a prefie operator , — ars us a a tho valiae of te exprewion | and thin increment by 1. This le Known as neers operaker, pe! _+ Relabienal (comp eval (comparison) oper alors aw bo compare vals ‘if + Logical operakor A —— Ane logical relatiouslip bfio duce ey ions and the resust it zero a ale) er nonzero Ckrue). F ~— — Jie ade 5h \naiiideie aide oe —— ba auc on a i—} iL —eperabor see) phion c cxansgle sttoflis edhe tg al iii HEAL cn I \ 573 WW 5 dus criplion = Pikutize “AND [ | \_ = Bituwe Of nr ~ Biluuse KOR | mahah om — > bilusige ont!'« complemmnb <— || ec pitusize te} obit, i q >> _bikuise right «| ilies ee ay oT a — i explainabiow & alesis A “ep AND = och corresponding bit am id [i S hethatiaonan dees |e J = wh a=i2; Cin binary t40) | 7 = ntb = 10) Cintimary— toto) | . Ink c=adb) C, pan." 0; a L reli 0} ; ( | t b eeiai0g ee ae L SOAR like logicaf AND h 1000 [ Fe i =r wiabasm i in-b= 410; 2 ink c=a\bs valet Cada o rebum 0° “= 4p iais (inwep atuMeaZhl iL be ~ thu ic the andere ol” Lig RAMaOR eee | A010- “410 Ei ro wkhy Win ln det ral Aas prrih.C La" ,0); return 0; Laan oie ee a + GW one's complement = unary operator i = sempre Ink a= 6; Chinaye 101) eg b=~a; prt ot i a tei Og a = 404 Cee tle a ba De th 1 Os wie werca) = thik it dhe ander (convert 40 decimal) | + BWW tft. shift i = nkax = valut < this shif M4 the bits eb value el =Eg—* int ass: Coinary 0404) int b= a <441; Senet pt tt TT] 11 an Sey + = 4010 ~conmurt to drcimal = 10 a = 7 r i the wolue by 2” Eg— 6Sx2' = 40 =x <4y Sienal “usork fer RUBUG ad iL_becomas undefined if y value? joe hl SS = Ani shalt the bits of value right lo positions ed - Eg- wh a=20; Eanes Bist let 727 ee Chinary 010100) = 000404 =e nor may gine garbage walut dae) SPT to undefined behamrour 3} « — When dealing with we nundbers in fi left or right bituudce shift, iin ordor tp ‘a (Re conmert the numbers inko binary, A = convert the no- inke binary by just il, f Ae noouilede ery EE eS CL i a ! — See ey >In any bitwire quabion, ike the loiaicy | Seas tho binan te In aaa oh ae | | O|: “ sites using fic a good. practice. forn_of- dhe inbeger Udit all 5 bite Lo Queid. any error _| gima added is dl add 1 Ao ib Loqebher : sizeof €) = 40 find ae sizeof an oberg -_ || + tune? = bo change the dakatype 6 es alla ha uaiable tie Mil le il b re kg iMoablep asc a eine | ay ee So) eee eee ll 5a) toda a | 24) | Precedance perakor: = |e 6 | = dokermines vant ov priority_ef an operatey ti 5 | a Asso ciakivity. of npekobeity wit wef . a ‘i otder in which several | as eae perotiows with equal precedence tye | L [- idinpiled Indies tae | aia aaa d i (aie | J ‘operator —_ducriphion assoriativity i Lo Paxenthevis : Jef 40 vighk | } ee Brackets fi 2 Member select via object nan. " =) Member celection via pointer __" __| 44-- osttix inekement /decrement te cinco He ieee 4- wary plus [rtd " af Logi eat negation/ Pia! comp: u dadalype commotion (cast) Hight to lefE * durefoumct “ 4 addons aire of determine datatype size “ *//. _ Niulbiplication /Divition/ modulus the tonight re Additien] substrachion. c<27) Brkualse sit Left] righl <= Lets than] Lem than equalfp 2 a Grealer He Crone al fo " Equal tof not equal fo zi 2 Bildize Ann a fs. sal f — Whuies woh EP wits | ee See lee nk ee aes Logical An — " | ie logical 0 i Ps e Nernony conditional: . —vight'bo lee | fea —Assignmne —__ = — Fit the “haaton| s fcakion/dierion align, hehe modulus [itwulte AND assigns = __B\wl XO OR _oMignmenl ry Q» Whak'Il_be the output of the following ¢ code? i ; | : Hinclade< stdio:h? Bias t . inl matin Je) e ae a & bidet iba eee pee Sh |S 4a de ueaid Rpth WWieue | _— ae dish ioe bd Au" aye, A); return 0} 7 \ a Zo | + —_- pa) 42 a a ll pd) ____| : J y ea Laser ante gues to emalaake tb a ikic | r | _logital AND, ene cide 0 confirms oukpub. | | Hower, lo nenur got increrubed= | 25) Codes | | f + \srike 0 program to dikplay a mage "Hello Aslorld” on _.tereen #indude

You might also like