chapter 5-programming

18
Chapter 5 programming

Upload: aten-kecik

Post on 31-Oct-2014

9 views

Category:

Documents


0 download

DESCRIPTION

 

TRANSCRIPT

  • 1. Definition of programming language. A programming language is a set of words, symbols and codes that enables humans to communicate with computers. It is a language used for writing computer programs, that direct a computer to perform computation and to organise the flow of control between mechanical devices.

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. Machine language is a set of instructions and data that a computers central processing unit can execute directly. Machine language statements are written in binary code, and each statement 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. FOURTH GENERATION PROGRAMMING LANGUAGE- The fourth generation programming language or non-procedurallanguage, often abbreviated as 4GL, enables users to access data in a database.A very high-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. STRUCTURED PROGRAMMING EDUCATIONStructured 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. Differentiate between structured approach and object-oriented approach in programmingStructured approachdifferencesObject-orientedapproachStructured programming Uses Object oriented approachapproached uses a top uses objects.down design model.The programmer divides EmphasizeThe programmerprogramming problem packages the data and theinto module likefunction into a singlefunction. unit, an object.Medium programming Suitable for Large programmingproject.project. 6. Describe the translation method of programming usingassembler, interpreter and compiler.COMPILER INTERPRETERThe source code (in text Interpreter is used toformat) will be converted interpret and execute into machine code which is a ASSEMBLERprogram directly from its file consisting of binary source without compiling itAn assembler is a computer machine code that can befirst. The source code of an program for translatingexecuted on a computer. Ifinterpreted language isassembly language the compiler encounters any interpreted and executed inessentially, a mnemonic errors, it records them inreal time when the userrepresentation of machinethe program-listing file.execute it.language into machineWhen a user wants to run the language.The interpreter will readprogram, the object each codes converts it toprogram is loaded into the machine code and executes it memory of the computer and line by line until the end of the program instructionsthe program. Examples ofbegin executing. A compiled interpreter-based languagecode generally runs fasterare BASIC, Logo andthan programs based onSmalltalk. interpreted language. 7. InterpreterDifference CompilerTranslate programmingMethod Translate entirestatement line by line andprogramming statementexecute it immediately. and execute it later.No object code is saved. Object codeStore machine languageas object code on the disk.Interpreted code run Running time Compiled code run faster.slower. 8. Basic elements in programming Constant declaration ConstantsDifferencesVariablesconst costantName = value Constantscharacteristic Variables cane.g : const PI = 3.142 retain their schange their const gravity = 9.8 value duringvalue during const discount = 0.2 the programprogram execution.execution. Variable declarationDim variableName as datatypee.g : dim studentName as string dim noOfStudent as integer dim schoolFee as double dim DateOfBirth as date 9. Integer DoubleInteger data type contains any Any number value that may andwhole number value that does could contain a fractional part. not have any fractional part.Differentiatebetween the datatypes Boolean String Boolean type consists either aAny value that contains a True or False value. Programmers sequence of characters. usually use it to store status. 10. Differentiate between mathematical and logicaloperators Operator is a symbol or notation that tells a computer to performcertain actions or operations.Mathematical Meaning LogicalMeaningoperator operator+ Plus AndAnd operator- Minus Or Or operator* Multiply/ divide NotNot operator Comparison operator Meaning > Greater than < Less than = Equal Not 50)If (mark > 50){ {Else}{ Else{}} 15. latest programming languages:Fifth generation language Fifth generation programming language (5GL) is an advance programming 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 will automatically code the program based on the problemdefinition.Fifth generation languages are designed to make the computer solve the problem for you. These languages aremostly used in artificial intelligence research. Examples offifth generation languages include Prolog and Mercury. 16. openGL (graphic library) OpenGL is a standard specification to describe the standard ApplicationProgramming Interface (API) for 3D/2D computer graphic applications. Itsspecification describes a set of functions and the exact behaviours that the 3D/2D application must perform.OpenGL was developed by Silicon Graphics. OpenGL is widely used invirtual reality, scientific visualisation, flight simulation and video game development Natural 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 the input to program software. Such a technique would mean less technical programming knowledge isrequired to write a program.The programmer needs to define the program using normal language. 17. End chapter 5.