0% found this document useful (0 votes)
13 views20 pages

Chapter 2

Uploaded by

Divyanshu Rawat
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)
13 views20 pages

Chapter 2

Uploaded by

Divyanshu Rawat
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/ 20
Introduction toc Language Describe Generation of Languages To Learn ston of ¢ Language Describe Fst ¢ Program Describe Strctre ofa ¢ program Expain Character Set of C Language Expain Words ina C Language 6 oeeeo8 Arie oar egal sec of scons wit sy peranmig nga at gles computer to acheve a predenned soliton, The process of wntingya computer Hota sealed programming. General mary computer progims av combed fe ke Softwar Aoftwre ia colecton of aierent programs, procedures snd documentation combine together perform 8 task using computer. Sofware casaied fy too catego. system Softwa an appenionsorenre. Sytem sofware Isa clectan cf programs tat alows an eticem raion between the Paewareef'3 Computer and te ier pertng. syste “ansat e,aa oder are examples o s)tem software, Appa selnae ia clacton ef programa alos user to prorm 2 specie dats processing actty on 2 computer. Toe daa Procesegactvy canbe of anerent pes such 9s manasngstounts chop pulestion (OTP) Sntabasemanagement. snd communistion. ‘ne JBM ask wny do we need to learn 2 new language o write a computer program, Why nt Simpl wits te progam Inthe lngsages wn toss. sien ss Engity, French snc or Stank? Well te reason Is tata insucton wren In natura guage st tines ca Pav aiming Fr compte sans fo work een hss ness tb aod A progfmming lngiage is now 38 formal engage andi ere from ntl angege Coast of rar ues 2 rata angag aa sto pede ron Sloe Sy the ngage designer ‘Thase rules frm te sat of ht language an cee how to wre ‘stuns irs programing ngunge, Toe res species sso quatante tht on ntact wi ave ane and only one meaning. To an» programming language. we ony need t ler new ‘main eee esr intra irgooness fr rape we want pk or wre Fe lngsge ety, west nena to ante aroma of Hn nae Ths pla aanses in bette generation of arguoges sory of 3 formal ngage eles C reste te propa, and te corset sted fo wrt program mC erguage The wor In laguage re also cscussed, and aly, the chapter ends withthe creation and execution of C Progam prea wate of 2 computer “hardware. From gorse nto" erty anguage generations ne ration of CO wih te evo" rye promeamming PADS ving tangueaes CaN Me enn dca = 4 jsted of strings of only tw: + Pen tinue po amy a Brian aye eee tron moo, diniegoe St ote fer second anrtion a sr ee aay om pci ri cmp os ra de samen me rete ant see te pee ie a Saute neo om on seer a scr eter me roan wo mcr Ae era eet ip sae c= ee LD cemoer yaar true Howe sereeecines Yar router a's a i on rae Sonos 1 Third Generation ‘Trigeneration programming languages became a boon to the programmers. The: rove ore natal means of developing programs by enabling the users to writ Hovrans wing Etlsnlngwoe sh se sates of» progran, Such pogtsoas languages are in use today and are called high-level languages. (sf the tic. generation programming languages named COmmon Business Oriented Language (C0801) became 2 sucess language used for writing business appicaticn es anus busines domains. C language also falls inthe category of third generation raupefoia sone ators cone as a midleleve language, The sistent eral, howe the dacusson on Ri ost ote scope of tis book. We wil cone Fourth Generation The sage of stcond and tie {and person The ffx of, rater eae of onmrration languages needs the user to be technica soupuiets In most every home has resuited to ae earamming languages. programming langeace 2.2 49 designe that even nontechnical users can develop thelr awn applations. The main focus when using fourth generation inquage Is rapid development of apleatons. Report generators. query languages, and. apleaton generator are examples ot the fourth {eneration languages, = Fifth Generation he 4 aogerrtonpsranming rao s bse on te concn of sing robins Using constraints given to the program. rather than using an ago writen by programmer. uses the domain of artificia ineigene (alto obtained constraint 2aeed folitions: The fith-generaton language can be coniered ae an ttmpt to make a ompute behave siniar to human bang behave Future devlopent inthe ara ofA may result in programming system tat accepts spoken statement from 9 see and then generates a computer program intended to produce te reaured output Today, none ofthe hve anquage generations mentioned eater has become obsolete. We are using all the fve generations of anguoges at rome pont of time, The ure may fe thatthe st and second-generation anguoges ae not used by inher ety. Bu Is eens se rey te an wot ses Komi, Te eon te Same given in he endo his chapter 2.2 History of C Language The orgn of C language dates back o 1872, Dons. ici I the man whe owns the ret of cresting the language. Tewas deve from the Bane. Common Purpose Programming Languege. common kaown as BoP. Me am a ceveapng C ngunge wes fo bua a rust system sotware, However became» pet ofthe programmers nthe ‘coming yes, and as been used fr devloping 3 hind of roftaare. Hence 1 as come tarbehnown a a genera purpose programming 9.392 [Athough crate in 1972, was standard n 1989 bythe Ameren Navona! Sansa Insite (ANS Since than. came fo be hrown as ANSI C. Vengo sch a8 APD Borland, Merosor, ond IBM have but ther own versons of and © compiers based on the ANSI standards Some of em fave even provded_anlntegfted development favrenment. more comony, krown 3b 196, for easy and fast devecpment of C programs. E18 A structured language for programming, 1 sows the program to be spt inte Subprogram hnown as function nee generate. these futons ae reusable. Set of ten renctons then consutes 2 program The approach of spit 8 program Into fubprogram Is known as rodulr programming, ‘THe maul approach of programming Fetps ce to'slve prot rising Inthe exgn of he program esi 25 we have to Concertate on sty ene function rater than an ene program. Usuny programs feta C anguape can be ported to ferent machines having diferent operating Syn an cones wit aost reggie moaieaon Tus is coniered to bet poreble ngvage E Fes surprising to know that we are surrounded by C programs. Aosta operating ystems suchas Windows, Uni. and Linu, have & large bocks of C program codes In am: you rene te code om these opeesing systems possibly the entre operating stom ay crah,Databses such as Gace, MySQL. abd networking proces aso use C of the € programs if gormtion Teche predefined ste fs struct ow Be nehuae Mat ‘ Feup towards Tenrnto8 ‘e Languages") sows to et a ness wa one of ea ocwe pore eT eto _ agree 0200 Language) towards leaning C' working of rogram 1 ne is not Incuded In me feed for aocurentation purest sr aneder fe, Next. main) 15 Koo ncn as an ul cx a uray fonction. eeu by wers as per tet requirement. 7 Tag hata user can make use oF in 8 BS sere understand the structure of 2 C Pros™ 12, Program 2 a Language «24 Wo ealeuiste e\rcanter Betictieere, . tsvieget fret enter the Valve of cau Pr atrasivs): 3s Serre racivs; | > Tee se a anion oF clrenteance Tlreunference of circle with rad in that iniates the purpose of poor oe directive that instructs the complet nce the contents of fe stloih This fe contains lformation about the nblt functors te sss symbolic constant PI hat has value 3.14. Tis statement aso Me preprocessor drscuve It ituc the Waster to pct Ee Ar Pt withthe vlue 3-18 before executing te program Joa iser-deined function main} 11s 2 most fo aC programs beginning of function man) two varabes {rads and Tecimal vues, The ter variate Crs Mend raniplation can alse change the stored ls He abult function pein rit 2 message on he mnt crt. These varales are capi of inte unetion scarf to red 3 value of discussed i decal ate cP functions have (expression; a formula to Hmartge along win tne vas of aver 2s and sere. . Heyer re tern. we St Say at Sg messy Pocono Star open ofthe program. but a perma! Breer uc vcs cere Teste habe rn rm Proens 108 2 00 yyy grenadine ny €or, Mince COTA wT Tan an ae The con feces aN UN ss ect eral) eeu enc ove oar ana udev ing toked at two simple Cr ral tne complete structure of a €Proa" Structure of a C program collection of blocks ced From Program 1 and 2, we can say that a C program 15 @ From Progr tenon made up of one or more statements used fOr Performing taped tak. gre 2 shows a complete strutue of Program Figure 2 shows that to section sections are optional sections and may of may not be pres: Pogtam However, the tmpusory section tat cman the function main wl a be present na ¢ program SY uh fh scons town In Powe 2 se cscs In dal ne fo = Documentation Section ‘Documentation section sa optional section nthe structure of a intcte. ris used forthe purpose of eocumentaton sna ray purpose of program. author deta mportnt log! aspect. ae ares pan eas sctiaa eal coreren ee pening (*) and closing (7) tokens to represent 2 tnclosed between /* and */, It Is considered a8» cor processed by C compiler andar lef as they ae efor any fea tuncton Gjamave ove Fomine rst reprogea Hepa fries aes ty aot be presen emai wa in te fotiows fuaes $F eraion oom es inc regam canbe sed aye na pont arments tn te foci 0 mene rssh Bh coment canbe 2 sglneconmert 2 me Pimefcommentssrelstecin tive? Tage proves one ote st of fokens De seen In Table 2. ¢ nt AC statement that Bis not processed. The cha sgl ine the comment exceeds fin ely we an also pref exc ne Dy Constant Definition Be ace zoe s sed to dete ay smb Retepuce ai cccrrences of aymlc consans pene constants are usualy ceed usa OP ec programs. Two eames of te symbaie Teale cennes a symbol constant P04 Beare camatant fo pis were. Pane Sr ce of 314 and print wit nat Ne ide Section aerve a uge ut of mit of teary rons 9 99% an sar. Tes Besa rt Fed on ota os ue be ower, and ancien sar 1 US 1913 ay [ae fe Ped ntrmaon about ese neon. nC. Sena es at Nope le exe TH Ta 1 eh sa programs nce Ae ist of header les avai Daath Append FH OOK slobal Variable Declaration Section Pear crass everest Bae ee yn es escape othe vroble, wih 6 decided, or ecg cay Hes (). TOE on pega se pete varies fads and we ON Se ae sr: Tee ves coat be aed ov MOP varie of he eerie nate foc, such a arabe 5 HOw Ot ed ae etre eg ate fons The gataled cision ofS Tis waa pe aon in chapter dealing wth futons i C angus, ‘Main Function 1 arms cannot We main). Tis 16 the function fon ‘bere ai one grogram starts. The control i fst transfered tos Ft thers, the es of te operations ae cated out [9 PFOBaMS | 372 Fat alvin) the probe part ofthe function malo 11 posible Na greener eet ein uneton main uses Ie or so} User-Defined Function ‘program pres us a ay of sting stage program nto st of. “These functions can then be used Independently i tr Fseectonsr = Say prepa. nts subsection, we wl Cee escent cvozna ny Eoe 2 ni on, sa ot pogo Reape ota epee een fer amp ies te ean ec Fr ca penn Santa esa campe ate CT > royom3 TF Program to wat tioly two runbers *7 include Chapter? took ists the ASC values associated with sltferent character Examples of single-character constants are, j 7 and 7 «© String Constant String In C represents set of characters. It Is d ‘enclosed within double quotes. String constants don't have any ASC with fC, string constant “H” Is not equal to slagie character c happens because of the way In which these constants are stored string constant “H" wil be allocated two memory spaces, while” wil be ‘one memory space, Tis Is due to the fact that strings In C are ened by null character. Examples of string constants are “C Programming”. “La = Back Slash Characters C language provides a special twocharacter constant. These constant slash characters or escape sequences. They are known a5 back sla first enaracter is always a back slash (\), and as the output of these const Drntable character bt white space, they are also known a3 escape sequence Simla to single deine. includes ale named define In © program. 1». Visa ala singe character constant. The etesion of C executable program Is exe. %, Get vat sting constant. YA To include z = symbole constants in € program, we use Temas ens cnt in € program, we use documentation selon Saba me et san acter ue Gems al) represent vavable name os. Practical Exercises Gh lw paces 2 ara conver a ns pga oven cenit sa eaaR Ht cI me fp mane inte program to accepts rune kilometers a mf ate MEM eo Wate a pogran SC number W and ing height. cept a ts square,

You might also like