Вы находитесь на странице: 1из 23

CS101ComputerProgramming andUtilization

Lecture1 BackgroundandIntroduction
TueJan4,20102:003:30,FCKAuditorium WedJan5,201011:0012:30PCSAuditorium Prof.RKJoshi ComputerScienceandEngineering IITBombay
Email:rkj@cse.iitb.ac.in

WhatisProgramming?

Trainingamachinetosolveourproblems

Lookatthisusageoftheterm'programming:

thebrainisprogrammed

Bythiswemeanthatthebrainistrainedtodo certainthings,ortobehaveincertainpredictable ways.Herethebrainisthemachine.

Aprogramrepresentsknowledgeaboutdoing something,andamachinestoresthisknowledge andappliesittoagivensituation.


Examplesofprogrammingin commonlyuseddevices..

FanRegulators Accelerators Applyingbrakes Failsafetrain signaling Periodicroadtraffic controlsignals

Pressurecooker safetyvalves RemoteControls VendingMachines Telephones

Characterizingprograms

Input Output Logicthatproducesoutputfrominput Identifyinput,outputandthelogicinthe examplesgivenonthepreviousslide?

ComplexPrograms

Aprogramcanhavemanyinputsandmanypossibleoutputs Forexample,object'telephone'hasacomplexlogic

Keypad,connectionandconversation,dialtone,busy tone,ringingtone,timeouts,calltransfer,caller identification... Programsincellphonedeviceshaveapplicationstoo.

Similarly,speedofavehicledependsnotonlyonaccelerator position,butalsoongearposition,loadinthevehicleetc. Theseadditionalparametersarepartofthesystem'sstate..they arehiddeninputsinsomesense..

HandlingErrorConditions

Programsneedtoworkinfailsafemode.

Exampleoffailureofautomaticdoorlocking systemincars Anumberconversionerrorcausedarocket failureduetooverflow..andtheredundant unitalsofailed..guessthereason?

Manymoreoutputpossibilitiesneedtobe considered

Someexamplesofcomputer programsthatyoumayhaveused

WithdrawalsthroughATM OnlineTrainReservations OnlineBanking,moneytransfer Desktopcricketscores SearchingthroughtheInternet ComputerGames Mediaplayers Socialnetworkingsites

Someexampleapplicationsfrom EngineeringandScientificComputing

Designofmachinesandsimulators Weatherforecasting Imagerecognition Bioinformatics Speechandsoundanalysis Naturallanguageprocessing Mathematicaltoolsandprograms Designandprocessingsoftware

CommonProgramsforprogrammingand utilizationofcomputingsystems

Programming languagecompilers andinterpreters Operatingsystems Devicedrivers DatabaseEngines Tableviewersand manipulators

Documenteditors Presentationeditors Commandsthatwork oncommandline Htmleditors Integrated Development Environments

Atypicalcomputingapplication

A program

OperatingSystem ComputingHardware, storage,media,networkingdevices

Amoreadvancedapplication..

Database Engine

A program

OperatingSystem ComputingHardware, storage,media,networkingdevices

Amoreadvancedapplication..
Database Engine

A program

A program OperatingSystem network ComputingHardware, storage,media,networkingdevices

OperatingSystem ComputingHardware, storage,media,networkingdevices

Everythinginthispictureis associatedwithprogramming..
Database Engine A program A program OperatingSystem network ComputingHardware, storage,media,networkingdevices

OperatingSystem ComputingHardware, storage,media,networkingdevices

Haven'tyouusedsuchasystemearlier?

WhyDowestudyComputer Programmingandutilization?

Introductionto

Usingcomputers Developingprogramsorcomputations Youcanlearnadvancedprogrammingonceyou haveunderstoodbasicprogramming principles


engineering,sciences,management,business,entertainment..

Basicsofcomputerprogramming

Applicationsofprogrammingareallaround:

Programmingneedsdiscipline

Inabsenceofit:

Programsmaynotbefoolproof. Programmersspendmoretimeindebugging Programsdevelopedbyonepersonarenoteasily understandablebyanother Programsdevelopedbyonepersonarenoteasilyusablein otherprogramsofeventhesameperson Thedevelopermaygetconfusedbyone'sownprograms!

Aretheseproblemssolvablebyappointingmoresuchprogrammers?!

Thereusabilityaspect

Canyouusetheheatgeneratedinsideacarbonnettotoasta breadwhenthecarisrunning? Acarhasdynamoandbatterytoo..socanthatpowerbeused toplaymusic? Canthesamepowerbeusedtooperateavacuumcleaner? Reuseneedsgoodpackagingandsomestandardization

e.g.Nutsandbolts

Programsalsoneedtobe'packaged'nicely..programming languagesprovidetherequiredconstructs.

StepsinProgramDevelopment

Programmingisallaboutthelogicthatgoesintoaprogram

Youneedtothinkaboutitfirst,andnoteitdown

ThentranslateitintoaprogramwritteninaprogramminglanguagelikeC++

Typeoutthesourceprogramonacomputer. Saveit

Thatprogramisthen'compiled'

Checkthe'syntax' Producean'executable'version

Executeit(Runit!)andhavefun.. Lookoutforbugs..testtheprogramanddebugittofixthebugsyoufind.

SomeCharacteristicsofGood Programs

Welldressedwellindented,goodlooking,use ofspaces,consistentnotations Wellinformeduseofcomments Correctwelltestedorprovedtobecorrect Claritythelogicisexpressedclearlyinterms ofwellselectedandwellstructured programmingprimitives

Onemoreexample..

Aprogramthatfindsoutwhetheragiven numberisprime Thinkaboutinput,outputandlogic? Aprogramminglanguagehasconstructsto expressallthese..

AProgrammingLanguage

Likeanaturallanguage,ithasdictionarywords,youcancreate newwordsforindicatingvalues,therearestatementsand thereisgrammartoo. Providesprimitivestoexpressthelogicofprograms


Dataorvalues Controlorlogicalsteps

Numbers,characters,strings.. Ifthendecisions... Andmore..

Aboutthecourse

Utilizingcomputers ProgramminginC++

Variousprogrammingconstructs

ApplyingProgramming ProgrammingAssignments,Labs

Let'strytounderstandthiscycle ofprogramdevelopment..
Think Edit

Compile Fixcode syntax

Fixdeeper program design errors

Fixcoding errors

yes

errors?

No

execute

yes

bugs? No done

Observetheactivityboxesandthe forwardandbackwardarrows..
Wewillcomebacktoitwhenwewillactually developprograms. Manytimesyouwillendupcombiningthefirsttwo activitieswhilesittinginfrontofthecomputer..So youmaymissthedistinctionbetweenthetwo leftmostupwardarrows..watchout!

Вам также может понравиться