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

PIC chapter 1. Basic Of C Programming.

The document outlines the basics of algorithms, including definitions, logical development, and the use of notations for programming. It emphasizes the importance of structuring algorithms step-by-step and includes examples of basic operations like addition. Additionally, it covers variable declaration, data types, and operators used in programming.

Uploaded by

vrushalikabade36
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
6 views

PIC chapter 1. Basic Of C Programming.

The document outlines the basics of algorithms, including definitions, logical development, and the use of notations for programming. It emphasizes the importance of structuring algorithms step-by-step and includes examples of basic operations like addition. Additionally, it covers variable declaration, data types, and operators used in programming.

Uploaded by

vrushalikabade36
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 33
Basics of | Unit-t » | Define alspeithes va Oefine ‘AlgetSthrn fig ae e Algoel then 1S deFineias: TFS athe Step by step doqic L ofS Program cto sowe cpeeiric Peoblern + — fens BE pF2 a0 ned Toul ete Notations used Joe Assignmen) Gtalement cand fe basic Cont Sacre LL he fpr - (teal FS, siege ask jrequeg degic development and’ Cannot be dent ie aalomabeal ny bE Tt eequives Yyagjoug Consideéations “so as 10 L develoP an aigee|then chat be betteg and. L eCficent - je [The aa eedes oF ageeithen - : Hi 1 ok ie a The _algpéithro: must bt Staep oth © ier" L 1 State eat and end ith “sie” oe LL 2 [To Input foom the user ‘uve will Use ~anpat or Read J gtateme ad - : iL [To dieplay outpad 00 monitse We win use Péfnt | stafement Y - The word is 10 display 43 willbe entten In doubie — quotes while vaeiable whith © value arenot display — atten the do not warren in double quotes - - i vil @ Scanned with OKEN Scanner oo wewill use basic Tene Sissies indicate ofeeation. To>- chetx tthe a tonditonsy weuse Fre Thiease? i i ea © Te, jum from one Step Fo anothee Slep we Use "GoTo" S lq Assignment OfCtajons are Use i - si9q Seamp ie NES METH Tie 1oP dd ey 1 i ler TRE {i Sy write cugeri thro Aor addition of foo: num bees” ep t . starp. nin : Step2 - Dectaee the Tagjane Abie Steps= | entees he venues SS Step 4 o= Oe Q¥b. ba bay steps = DISplay dhe ous one. Wtep et ior ae estoP ea + fag @ Scanned with OKEN Scanner “O elasenate y. wewill use basic aeithmabi: ofFesiors + indicake opeeation. *|S-<- “Tow chek the “tl" tondittons weuse The Thrase! 5! rp ey one otep 78 anathee SP ae 6. “Te, jumP from use“ GoTo" iq Assgprent OPCEATHRS ave Use The - sin exampie ee Ate Poe ee. brese vie f wrnte algerithim fer addition oF foo! num bees. Lester Taro fea 7 Peaaee the Vaejabie Qi bic gtepar entee: che ‘varued of a rb tep 4 =f eH atb. i be nbep S - DISplay he tesutt of C. TiBtepe oe ot stor : } x. tee afi elarn tq wlan AAS ASST] - + @ Scanned with OKEN Scanner write the cugorithm che Soap: the, Welues 6° two. =e DumbexS Lots, (niida 7 / ae Setinbutivhs ot et en fa L Step? ~ _Oeelare the vaehebies a, b fem P a Steps. entet the yauues ofa and b- = stepu = tempeg ed [steps - a=b D _ b= Femp: th : — : Bi stad. | bisplay The weself | = qoiShOpi oe ; J ven no" tep6- MeidgPine mk eo. \ \ = Step) - bse nots odd no. rep & - &top- Seed y @ Scanned with OKEN Scanner Define—Fewe haat Waa ae . _| Fiewchaelis bic | tepre.te - epaihe era mv dele fla kad Hite oa zee) I | Preess Li: IS Tadivales sekoF oferakion , - \ike iassy ment ctneremench - decrement itializabiom ee fl / / 3 Tond | cabpa- Peek, [ fo fed La >. r in| —— r 4 Fess fi I\ Decision block | \/ tnd Teles dftlsina—nnatking Skutement¢ @ Scanned with OKEN Scanner ae i nbers. 2 oo — 2 y = a (siat) — ¥ || Od : [Dedare the vaviabies | @ Scanned with OKEN Scanner Cet al @ Scanned with OKEN Scanner f | & ah Lee ao oz VY oT HCO @&) page. ie Ane studure of ¢ Pregtana 2 Structure of Cc Preqtam_- Documentation ox Comment sediin __—_t — _Headet fine Section ov Preprocessot irecbive Section jot cLiakeing yeution } Global Vasiabie declaettitn setion. Defmihm section - mala ©) Pevoeahion Past Execution Poe} oe vset | defined sedion id] | & Lynette bo d a dy —_ 7) [Powmentatimn o% 32 tomment section - Potumentalomn section also Kknaon as Cornment on : - Comments ave _ mets e ot. undetstand) 2 preeg tannin -______ pera 5 Th means useé Shoid tundesstand meanira, of eomh slalerment in prog tanning : = ej- C=ath jx add aand b and skve The “-eeswt at vaeiabie ¢ al. jwe wette the Comments oun where Of the pregzamm_. f @ Scanned with OKEN Scanner 6) » Pes LETTS See ‘TCommends Shouts weinen—o_achnk & fotwoed Slash 1 sae ey [& KL. (ornments ate ering ith ferduedslath any asdéik fends with astelk and fordor] Slash . : Comments 9t€ no4 Com pile and net exccufep 2_|Headee fie secion ot Pepto cessee seation of _cUnking section 1 > X= [Header ite Ps (ouection of dibeaty yncting i wWhewty fintions tike induded Stdiohd L- Libesey fanctioh means nebien veeeady dea Tn Headet funchion ! | il Pinclude éstdtoh> ——_uibeaty Les ; Pte proresset dprechi ye. or Stdio_means — Standaed } pet out iF ineta aint Sscan€ tink fet Tee a. B Fnelud € Lcontohd Hoe tomo means tonso\® Jnpat oud pet itorfalns seth Os a cme used Fo eat us hold the Screen Cor ST SEEPRECEEE EEE Eee peepee ee Se eee @ Scanned with OKEN Scanner | fe pre means -[rest process [es ‘Which (an be Process Known as preptocesset dizective Seetion q Linking sechion - J Phat elon ike [ike |Inks object code ePeokes Soe ditectve secHo . the _Skebeme nth ,_ before Compilation we wvte the - Fsevecl beaty function to mato freq earn - © oO <4. Tn peegeam ! uses: Peintf & sean’ [aad function fs So Compliee Compilation _.o _tompitee (ode ‘of \i bene TJ Rinchwey SO out Compiles dosent andess habits. frinif scant fundton So thet define iin the heagee IC enkezabe - ob: fije dueing Coun chiro the sb ject linkee function 4S LL | main Peog tam: " -_| pefinabieon Sechn — |ts used to define macto.. 1 Hyeline _Pacto _(onstand- I macto (an define _wppeet Case, | 9 F define PE Sle [- ratte _wtso Konan Symboetahe Constants . I Bt means phe yelue ofS the maeto is nevet | Choy The. Value $0 qf we try to The. value $ com Pi [tz Chere” genetate e ttrk message . L @ Scanned with OKEN Scanner L Global Vaerabie declaestion means leohich tomb hs oo tog fam_knawn_as —« as slebel vag it denne — ir dhat vaseiabte used jn aul Péogéam “Global Vatiabie declatation, Thexe ave wo ohyres of Vatbabie qevlasatten Gebel vottabie | and Local Vasrabte deeueal, the_Vaerable TEE Vielabie deaiaratten means . 4 Vaeabie which Can be dedare Jn Within a fund. knéon'ad “local Vaafane, dedoeation. —¢ VE emt ict sep ari hie = p> Lfynehton £49. ie 7 Sappose - the Vaeiables idhich Con be deus in Kant [Section ke: _theh used coly one saithin thet Aunebion i Vaetabies ply = = @ Scanned with OKEN Scanner Le YS aero: | Sy =—| | maint) fonction Section. levee CT. Frogtarn must have one maine) —Hanarlog yectron. this Contains too Poets qetaeativn faet execalable Pact - |n declatatin past used Can declare the. Nagiabie tha} vagabie, usedin execabebye Fatt - [Theve tS at least one pabement In executerb 1e fa tt: : : The execubabie Pact one open With Opening brace close With clostna brace. - The. Closi ce of fhe main hnction wedien J is Sigh ena the _ptogtam. | i Qu Statement jndewseskion Pe vectrawres ZZ oer end With ' Sernfcolon . es jnt a,b pri seonP Cyd vd" §a,€b) L ~ loses defined tunctim «> [ TThis function defined by The uset - i funchtom there isno need of —— oo Abts ts function defination — ‘tn _used_defind Semftolon be coure DiRT ha Cautly breaker we plracedin functim body t depends upon the pro _probiem we defin Mo of. Tamebionly In thel section , i @ scanned with OKEN Scanner ey. Sappos ¢ we Perform the the ag} . ~ Ope abn 4 a (eases { UT ore) So hexe ar matic“ Opctation dike addition, tub enutth_diva Phe au finectoms de Med in uset | thine Section fundamentals —Const-tuckS tn “¢! —= [A shacautet indicabes any ape dig Spettal Sen Synbal ; Jaa _|___® Alphabes i Uppeecase letteas:- fl to7 ! ze ond Tape’ tase letbedés ~) cal toy | EZ @owt —- 0 *rog : Byspetda) symbol - itinaudes ke” aos E ee ee @ Scanned with OKEN Scanner Bp, witiw tes s_ = vouva| \ LL \ 4 c_tokens set + molest | individual “of unit of ¢ Péoq.er a knowns (tokens . al classi Ercadon of c tokens: fal Toren § ! a oO Keywods - Can Keysoeds inc frepam ) * There ave that keywords ia Can be defined by a Dibeacy : : €9- Cink, ches ih wise a meaning of thet ‘keywoeds fine a by = J Compites cxtbeady aa | ty Spa anges 7 ~ 1 Ol tholifiee | -__Tdentifiee ‘Ps -aname fo dealt hy the 4 Name of the vaeiabye , finetren TL} steing . . sfeing Can be Jevminake By nao Chaeocle e Stems Can be Weltten tn double Quotes matkS Yella! Jeng th of that sting is @ 6 ANd 7 once _legierl Symbol Used to Perform opttabes {Ssh are cagheay 6 Peach in, "Muth © Petation, 4 Ct) V4 @ Scanned with OKEN Scanner yy * ES a . Ho ey ee [esis =a tala RES is chan ed [pa eae to Sit ee oF oe bat vaefabie ed which nevee chan ee | The -spectel gene ine - spect amr] S ja InpasS:—— yatut . pais Kegaoed rokeget Data ype datatype Ts a TYP of dakg whithis used in the Peogram - Bi Othee woed we Can soy dhak SVs used 6 ‘decdare the hee Vaelabit , “There crre choo tyres of dala Ay Pe- @ Scanned with OKEN Scanner rF o fee row oe Peimagy ata hype * 4 Seendaty | ind ae ‘tha € Ace oy oak ‘i ; void. Contan Data hy Pe : Pelmaey Cbaltt Deeived delg Use define in) tyre. data KyPe datatype . “They ave build They ave C They ave cukeady using Pelmaey defined by defined by the deta fyp eS unset C uibeayy”. v8 d Aet | | t np \euchure. > Int Ly function sunton, hag [| low bie 7 Poinkee be nurmecs | fio at a @ Scanned with OKEN Scanner rwress & vouva _ofeecors - —lopeeator is q Symbo| thatused do. pea form mathematica, GO. § Nog jee opeeatton, of NVadiables & values bis [opesator | L —[_ ds I UNaeY (wor! nN i L_ tnevernent Ae i Decrement - a fused to F sizeof. Ee Pelatena] f openk * ecvondieg, a 280 lennon _ Ib piktors e — > las conditions Assignment 7 overdo - Lc J tis vse d to heck condtHan . Ustng Fs \-Camby7atb. TAS psed cho check Three ov more than ftom) CXPression | @ Scanned with OKEN Scanner @ Birnty opcenter iflaithmectic _Opeeater's - wthmaliC esatorh at f oreeo)_-bddition (+) @ Subbaction_(- 9 © pruttipiidian Ck) @_ DNisiom: C1) @ module _diviston Ch) | finciade _ Bindude (Notd mainc) x Int ate] Trt b=105 nes C=a tbs .|PrintFO'\n addition ofa and bexwd , OS -C=q-b: PrintFC"|n_vaiwe Subtration ofa andc= 74" oy C= ake 7 eT, Peim-£c'ln_muiipiivation ofyandc eT ey C= a/b; Print€e'In division of G “nde erg oO: > i @ Scanned with OKEN Scanner vyouva PEERS EE oe tlt \ i] | I Tt C2a%b; [ faim fc" \n_ modulo divi stor of aand bio “hd oO: | gelth os, Ci 7 Assisnoment oPpetahee we Assignment Opetatee are used oassign the value of vadlable . ‘Assignment ofeealot axe a e = equal +o. <= def ShFY And 4 = Addition equal F T= _ttyht shiFtand. = = gubbathion jequal (Owe & - bihots and = mattiplicdion equate sf — A= bfroise [= divide equa to I CRUSE: y= modulo divide equal to. y= binarse THausive—, Syphon = datatyre vaeiabtename = yalu@, aq 23 Mnk at 16 ce ath. Hindode Cstdioh> ah fabte Minclude Void mahO 4 i intas 2/5 t InhG wa =! @ Scanned with OKEN Scanner - 1 ) veo] — cea : Printh C’ lo vote of C=2%4" CD; - C+=Q5 Priptf¥C™\n vatue of G=yd ", O} ¢-=as va Print EC Vaue of cH 7rd", C5 C RzAaAYS 3, Pxmtec'|n yvatueofc #= ¥g7, o)y Cci= ag PNET TN Value SPIE ITSO C =2005, LGys as Print Ff", ValtieoF C Aa, Oo cee 225 frint FCN vaue of o < _gtectee than = Jess than Latual +6 z 2 Creates then eowal tg ® ® D == equal to Qo} = not equa do P include votd_ mafnc) { Snt_a=215 jnt b=103 fotcs efrser cy if Ca=b) Y Print FC\n arsejuet to b')s % Use. PrinkeC™ln als nod equal tob")) % @ Scanned with OKEN Scanner pits of a Numbee. St can be used on Bipotse Opceato® ove used Jo peeken) Individuay Yntige NPC. Value Not float ) double V Bu2) By 2) Tyre azq foleoo) pb = S@iory Lopeeator meaning ae Tat aie tate | fs Bihoise An O oma o AG II Bihotse OR on L mals A Bihohse KOR. ole lo . a (own ple ment Oo a Jee eft shit > |r? 2 Right shifal- 4 tesut = q 5 1 |minciude b) x % Print € Cn ais Jreatee ethan b"); ese 2 printfe"ln ais not qreatee chhan p> _ @=S3 b= 205 if Cage b) P frinv FC" a Ts dess than ev equal fob”), 7 ase > Printh CE or rs t€d sie) ay if C b>=a) 4 ‘ Print" \n its greatee cthetn o¢ equal toa’): 4 A iF cal= b) PCy is nok @wal fo BY PSC § Pinte C In afsequate b')) F aden @ Scanned with OKEN Scanner 2d #include > 2; /* 15 = 0000 1111 */ printf ("Line 6 - value of c is &d\n", c ); } When you compile and execute the above Program, it produces the following result — t Line 1 - Value of ¢ is 12 Line 2 - Value of cis 61 Line 3 - Value of ¢ is 49 7 Line 4 - Value ofc is -61 Line 5 - Value of ¢ is 240 Line 6 - Value of ¢ is 15 @ Scanned with OKEN Scanner classmate. r Unaéy ofetatoe A_Opeealet “@hith Contains only one Opefand Kona as tuncty Opee ater. nceement | decsement ope eatos Tntremeot opcectee ave ured do Increase rhe volut of vaélabie byt Detwement oPpetaket ate. used 49 decred ie he _value of vog}abie by L ; PreincyerneAt - ¢ +40 \nt a=16 Ais ©) YEAS printfc™ Iny")s Post Intvement = Fnt a= 104 =att primf ("att Lo printf Cx") 1). \\ iii Q@|_Pre decrement ink a= jor k= — =, Pico Inx= @ Scanned with OKEN Scanner Oy!) =10 £ \ Fon" 9 lax rkOIse Opes adog Bikoise pee ator axe used to pee form bit level Opeeation . { THS Gn be Formos the. bimey opeerter Concepr (yy 5, Bi — Girnty Opeealogs ave. S OD _pinoise ¢_-AND gig 9 & 2 4 @ shoe og | + 2 ; @_ ginotse xoR A to L sory ° ected aca Lg ot eto oO ® (Comprement © —1 tio @ o 4 2a _ eft shift oporak - >> etgnt shift of: i exam pie a) Yor QeS + Si int be F @ Scanned with OKEN Scanner classmate. © 1ol + 14 oxo ibc ave. @ Scanned with OKEN Scanner @ Scanned with OKEN Scanner classmate a dale ege ———— [Leaice ‘Opecator -_|Loqicat oretatoy oreaed do Combines the too os Mote eejahion Jogtcale ~ | Tran be Peoduce Strse tesu of ue O& se ogtced Opeeafoes ave oatca And . J ey Dot, C3 Erampie eseuth + Sea 8 (S¥2)}- Se. SLO\\(SrD] Tore } Cs Vue @ Scanned with OKEN Scanner classmate J {| if — Example coe Try the following example to understand all the logical Operators a= available in C - Live Demo #include main() { L — int a= 5; b int b = 20; L intc; a if (a &&b) { L printf("Line 1 - Condition is true\n" ); if (alld) ¢ r an printf("Line 2 - Condition is true\n" ); 5 i } - — /* lets change the value of a and b */ L a= 0; i b= 10; if (a seb) ( Le Printf("Line 3 - Condition is true\n" DG — } else { i J printf ("Line 3 - Condition is not true\n" ); Lo } | if ( Va 6& b) ) ( = Printf("Line 4 - Condition is true\n" ); } \ @ Scanned with OKEN Scanner TInpek]outpal Formalin : cv dtniv] G. isiabe theuse Of Printf @ Exon fC) with Saiiabe. | _€xarnp ie - ~ x Plabe Jetsrov tof ‘pacORivmnd dared @. | Explain 7H nd. fermatid, JnpadCan be SbFain aie —} Sultebie Sxampre at 12 POOR? solaoron) Enlis ditto Somat Spe ashoith Sts_use- ° R. ‘ : Descmbe the § ntont € exemple of pean? Scant “Slehemerg = bio ont VVVIO59L 4 | =) ; tn i is Tesi data on the Standoed outpe deve Dpveclponi and" aoe he. Input from Standaed fopat device jee. | Fibok ameP pedal tec bese To fi on) Aisi and nubions On based on Formatting Ppremitted or not J sad Pog ) Texe are hon ermatiel a onions ove avanie inc. famely’ Print). to Pee moniter @ Scanned with OKEN Scanner gies : Petnr® — ae eb Peay ~The formed hig Casi lontains! The fetta! o> D chovathee_sef CAZ.a=Z 25, shea ee HB blank sPacee) fat 6) Escape Sequence . = a) fied width= “The width < of value conte a shed by by sresiging oie ud Diath. Tl tid ©. fea ea ug | Formed. oe Shasiee yt of date TAP =. for double date ILE 7 For lens doube ‘tate of daly YS —>~ for spring Vor array of chy A ne 7 he vadeatmay dala a Yo 3 och data, @ Scanned with OKEN Scanner [Eimer tao forirod au i frint RQ) The: tami paling ad a b), la “This amas aan Path The outpad Oi Th mel Spee Fier replaced with. srwiue oF B9, AX wehib Paik norpord ‘sean 0) bails if Syniey Srey Asedy of bree =F San FC” Feel Sri, “af o orp [dress of, verabeY; r_ Heres, format gpectfier, Shang) Contain, Verma _SpeetFier —fieid width and J ite re noes Sup pression i charade fn: > vol. a The ass fanmeny SUF PREEHD cheat Cy isusedeto — diced one of the! user Eoiened al “Tre address. of Varietbie ts obtained ck [hep of address operates: CQL mM | Exaropie = StankC'Y.d "Fee TKis istetement pS used cforacceph the int tyre Value ror) User, inthe Norrie YX , Tro. @ Scanned with OKEN Scanner

You might also like