Chapter 5


Published on

hci final

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Chapter 5

  1. 1. Definition of programming language.A programming language is a set ofwords, symbols and codes thatenables humans to communicate withcomputers. It is a language used forwriting computer programs, thatdirect a computer to performcomputation and to organise the flowof control between mechanicaldevices.
  2. 2. The generations of low-level programming languages with examples.FIRST GENERATION OF PROGRAMMING LANGUAGE The first generation of programming language, or 1GL, is machine language. Machinelanguage is a set of instructions and data that a computers central processing unit canexecute directly. Machine language statements are written in binary code, and eachstatement corresponds to one machine action.SECOND GENERATION PROGRAMMING LANGUAGE The second generation programming language, or 2GL, is assembly language. Assemblylanguage is the human-readable notation for the machine language used to control specificcomputer operations. An assembly language programmer writes instructions using symbolicinstruction codes that are meaningful abbreviations or mnemonics. An assembler is aprogram that translates assembly language into machine language. Since assembly languageconsist of human-readable abbreviations, the assembler must first convert assembly languageinto machine-readable language before the computer can readily understand its instructions.The generations of high-level programming languages with examples.THIRD GENERATION PROGRAMMING LANGUAGE The third generation of programming language, 3GL, or procedural language uses a series ofEnglish-like words, that are closer to human language, to write instructions. High-levelprogramming languages make complex programming simpler and easier to read, write andmaintain. Programs written in a high-level programming language must be translated intomachine language by a compiler or interpreter. PASCAL, FORTRAN, BASIC, COBOL, Cand C++ are examples of third generation programming languages.
  3. 3. FOURTH GENERATION PROGRAMMING LANGUAGE- The fourth generation programming language or non-procedural language,often abbreviated as 4GL, enables users to access data in a database. A veryhigh-level programming language is often referred to as goal-orientedprogramming language because it is usually limited to a very specific applicationand it might use syntax that is never used in other programming languages. SQL,NOMAD and FOCUS are examples of fourth generation programminglanguages.FIFTH GENERATION PROGRAMMING LANGUAGE- The fifth generation programming language or visual programming language, isalso known as natural language. Provides a visual or graphical interface, called avisual programming environment, for creating source codes. Fifth generationprogramming allows people to interact with computers without needing anyspecialised knowledge. People can talk to computers and the voice recognitionsystems can convert spoken sounds into written words, but these systems do notunderstand what they are writing; they simply take dictation. Prolog andMercury are the best known fifth-generation languages.
  4. 4. STRUCTURED PROGRAMMING EDUCATION•Structured programming often uses a top-down design model where developers map outthe overall program structure into separate subsections from top to bottom.•In the top-down design model, programs are drawn as rectangles. A top-down design meansthat the whole program is broken down into smaller sections that are known as modules. Aprogram may have a module or several modules.•Structured programming is beneficial for organising and coding computer programs whichemploy a hierarchy of modules. This means that control is passed downwards only throughthe hierarchy.•Examples of structured programming languages include Ada, Pascal and Fortran.DEFINE OBJECT-ORIENTED APPROACH IN PROGRAMMING. The object-oriented approach refers to a special type of programming approach thatcombines data with functions to create objects. In an object-oriented program, theobject have relationships with one another. One of the earliest OOP languages isSmalltalk. Java, Visual Basic and C++ are examples of popular OOP languages.
  5. 5. Differentiate between structured approach and object-oriented approach in programmingStructured approach differences Object-orientedapproachStructured programmingapproached uses a topdown design model.Uses Object oriented approachuses objects.The programmer dividesprogramming probleminto module likefunction.Emphasize The programmerpackages the data and thefunction into a singleunit, an object.Medium programmingproject.Suitable for Large programmingproject.
  6. 6. Describe the translation method ofprogramming using assembler,interpreter and compiler.ASSEMBLERAn assembler is a computerprogram for translatingassembly language —essentially, a mnemonicrepresentation of machinelanguage — into machinelanguage.INTERPRETERInterpreter is used tointerpret and executeprogram directly from itssource without compiling itfirst. The source code of aninterpreted language isinterpreted and executed inreal time when the userexecute it.The interpreter will readeach codes converts it tomachine code and executes itline by line until the end ofthe program. Examples ofinterpreter-based languageare BASIC, Logo andSmalltalk.COMPILERThe source code (in textformat) will be convertedinto machine code which is afile consisting of binarymachine code that can beexecuted on a computer. Ifthe compiler encounters anyerrors, it records them inthe program-listing file.When a user wants to run theprogram, the objectprogram is loaded into thememory of the computer andthe program instructionsbegin executing. A compiledcode generally runs fasterthan programs based oninterpreted language.
  7. 7. Interpreter Difference CompilerTranslate programmingstatement line by line andexecute it immediately.Method Translate entireprogramming statementand execute it later.No object code is saved. Object code Store machine languageas object code on the disk.Interpreted code runslower.Running time Compiled code run faster.
  8. 8. Basic elements in programming Constant declarationconst costantName = valuee.g : const PI = 3.142const gravity = 9.8const discount = 0.2 Variable declarationDim variableName as datatypee.g : dim studentName as stringdim noOfStudent as integerdim schoolFee as doubledim DateOfBirth as dateConstants Differences VariablesConstantsretain theirvalue duringthe programexecution.characteristicsVariables canchange theirvalue duringprogramexecution.
  9. 9. IntegerInteger data type contains anywhole number value that doesnot have any fractional part.DoubleAny number value that may andcould contain a fractional part.StringAny value that contains asequence of characters.BooleanBoolean type consists either aTrue or False value. Programmersusually use it to store status.Differentiatebetween the datatypes
  10. 10. Differentiate between mathematical and logicaloperators Operator is a symbol or notation that tells a computer to performcertain actions or operations.MathematicaloperatorMeaning+ Plus- Minus* Multiply/ divideLogicaloperatorMeaningAnd And operatorOr Or operatorNot Not operatorComparison operator Meaning> Greater than< Less than= Equal<> Not<= Less than or equal
  11. 11.  Five main elements in a flow chartSymbols Names ExplanationTerminal begin orendUse to shows the beginning or end ofa program.Flowlines Use to connect symbols and indicatethe sequences of operation.Input or output(print / display)Use to shows either an inputoperations(e.g. an input from theuser) or an output operation(e.g.print or display messages)Process(formula)Use to shows a process to be carriedout (e.g. calculatorDecision(if-then-else)Use to shows a decision(or choice) tobe made. The program shouldcontinue along one of two routes(e.g.if…then…else)
  12. 12.  Draw a flowchart to show how a program calculatesthe area of a circle.Print areaof circleArea of ciccle= ½ * PI *radius^2Get radiusBeginEnd
  13. 13. Five main phases in program development:Phase ExplanationProblem analysis  Identify input, processing, output and data component. Meet with system analyst and users. Ask expert.Program design  Divide all program activities into program modules. Create solution algorithm for each program modules(logicstructure). Design/ draw user interface.Coding(writing the program iscalled coding) Coding a program involves translating the solution algorithminto programming language usually on paper. Typing code into the computer using programming language.Testing and debugging  Manually testing with sample data. The program is run through computer, using a translatorprogram. Before the program will run, it must be free of syntaxerror.Documentation  Documentation enables new programmer to understand theflow of program Is used for future reference in case the program needs change. Explain the purpose of the code statement.
  14. 14. Types of error1. Syntax errorcaused by wrong spelling in commands(words) and declaration. Othersyntax error include case sensitive and wrong words command.the easiest error to find because they are highlighted by the compiler. Errormessage are given.example :Source code Syntax error : missing curlybraces }If (mark > 50){Else{}If (mark > 50){}Else{}
  15. 15. Fifth generation languageFifth generation programming language (5GL) is an advanceprogramming language which concentrates on solvingproblems using constraints given to the program.In fifth generation language, the programmer just need todefine the problem to be solve and the program willautomatically code the program based on the problemdefinition.Fifth generation languages are designed to make thecomputer solve the problem for you. These languages aremostly used in artificial intelligence research. Examples offifth generation languages include Prolog and Mercury.latest programming languages:
  16. 16. openGL (graphic library)OpenGL is a standard specification to describe the standard ApplicationProgramming Interface (API) for 3D/2D computer graphic applications. It’sspecification describes a set of functions and the exact behaviours that the3D/2D application must perform.OpenGL was developed by Silicon Graphics. OpenGL is widely used invirtual reality, scientific visualisation, flight simulation and video gamedevelopmentNatural languageNatural Language programming aims to use natural languagesuch as English to write a program.Instead of using a specific programming language syntax,natural language programming will use normal English as theinput to program software. Such a technique would mean lesstechnical programming knowledge is required to write aprogram.The programmer needs to define the program usingnormal language.
  17. 17. End chapter 5…….