LALA5 Programming

download LALA5 Programming

of 6

Transcript of LALA5 Programming

  • 7/29/2019 LALA5 Programming

    1/6

    CHAPTER FIVE - PROGRAMMING

    39 | P a g e

    5 PROGRAMMING

    5.1.1.1 State the definition of program.

    A computer program is a series of organised instructions that directs a computer to perform tasks.Without programs, computers are useless.

    5.1.1.2 State the definition of programming language.

    A programming language is a set of words, symbols and codes that enables humans to communicatewith computers. It is a language used for writing computer programs, that direct a computer to performcomputation and to organise the flow of control between mechanical devices.

    5.1.2.1 Identify the generations of low-level programming languages with examples.

    A low-level programming language is a programming language that provides little or no abstraction

    from computers microprocessor.

    FIRST GENERATION OF PROGRAMMING LANGUAGE

    The first generation of programming language, or 1GL, is machine language. Machine language is aset of instructions and data that a computer's central processing unit can execute directly. Machinelanguage statements are written in binary code, and each statement corresponds to one machineaction.

    SECOND GENERATION PROGRAMMING LANGUAGE

    The second generation programming language, or 2GL, is assembly language. Assembly language isthe human-readable notation for the machine language used to control specific computer operations.An assembly language programmer writes instructions using symbolic instruction codes that are

    meaningful abbreviations or mnemonics. An assembler is a program that translates assemblylanguage into machine language. Since assembly language consist of human-readable abbreviations,the assembler must first convert assembly language into machine-readable language before thecomputer can readily understand its instructions.

    5.1.2.2 Identify the generations of high-level programming languages with examples.

    A high-level programming language is a programming language that is more abstract, easier to use,and more portable across platforms.

    THIRD GENERATION PROGRAMMING LANGUAGE

    The third generation of programming language, 3GL, or procedural language uses a series of English-

    like words, that are closer to human language, to write instructions.

    High-level programming languages make complex programming simpler and easier to read, write andmaintain.Programs written in a high-level programming language must be translated into machinelanguage by a compiler or interpreter.

    PASCAL, FORTRAN, BASIC, COBOL, C and C++ are examples of third generation programminglanguages.

    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.

    xxxxxxxxxxxxxxxxxxxxxxx

  • 7/29/2019 LALA5 Programming

    2/6

    CHAPTER FIVE - PROGRAMMING

    40 | P a g e

    A very high-level programming language is often referred to as goal-oriented programming languagebecause it is usually limited to a very specific application and it might use syntax that is never used inother programming languages.

    SQL, NOMAD and FOCUS are examples of fourth generation programming languages.

    FIFTH GENERATION PROGRAMMING LANGUAGE

    The fifth generation programming language or visual programming language, is also known as naturallanguage. Provides a visual or graphical interface, called a visual programming environment, forcreating source codes.

    Fifth generation programming allows people to interact with computers without needing anyspecialised knowledge. People can talk to computers and the voice recognition systems can convertspoken sounds into written words, but these systems do not understand what they are writing; theysimply take dictation.

    Prolog and Mercury are the best known fifth-generation languages.

    5.1.3.1 Define structured approach in programming.

    STRUCTURED PROGRAMMING EDUCATIONStructured programming often uses a top-down design model where developers map out the overallprogram structure into separate subsections from top to bottom.

    In the top-down design model, programs are drawn as rectangles. A top-down design means that thewhole program is broken down into smaller sections that are known as modules. A program may havea module or several modules.

    Structured programming is beneficial for organising and coding computer programs which employ ahierarchy of modules. This means that control is passed downwards only through the hierarchy.

    Examples of structured programming languages include Ada, Pascal and Fortran.

    5.1.3.2 Define object-oriented approach in programming.

    The object-oriented approach refers to a special type of programming approach that combines datawith functions to create objects. In an object-oriented program, the object have relationships with oneanother. One of the earliest OOP languages is Smalltalk. Java, Visual Basic and C++ are examples ofpopular OOP languages.

    5.1.3.3Differentiate between structured approach and object-oriented approach inprogramming.

    Structured programming often uses a top-down design model.

    The object-oriented programming approach uses objects.

    5.1.4.1 Describe the translation method of programming using assembler, interpreter andcompiler.

    ASSEMBLER

    An assembler is a computer program for translating assembly language essentially, a mnemonicrepresentation of machine language into machine language.

    For example in intel 80836, the assembly language for the no operation command is NOP and itsmachine code representation is 10010000. Example of assemblers are MACRO-80 Assembler andMicrosoft MASM.

  • 7/29/2019 LALA5 Programming

    3/6

    CHAPTER FIVE - PROGRAMMING

    41 | P a g e

    INTERPRETER

    Interpreter is used to interpret and execute program directly from its source without compiling it first.The source code of an interpreted language is interpreted and executed in real time when the userexecute it.

    The interpreter will read each codes converts it to machine code and executes it line by line until the

    end of the program. Examples of interpreter-based language are BASIC, Logo and Smalltalk.COMPILER

    The source code (in text format) will be converted into machine code which is a file consisting ofbinary machine code that can be executed on a computer. If the compiler encounters any errors, itrecords them in the program-listing file.

    When a user wants to run the program, the object program is loaded into the memory of the computerand the program instructions begin executing. A compiled code generally runs faster than programsbased on interpreted language. Several programming languages like C++, Pascal and COBOL usedcompilers as their translators.

    5.1.5.1 Differentiate between constants and variables.

    Constants Variables

    CharacteristicsValue is not changeable duringthe course of the program.

    Value can be changed anytimeduring the course of theprogram.

    Usage

    Use constant when you want todeclare someting that wont be

    changed midway in yourprogram execution.

    Use variable to store data thatmay or will change during the

    running of the program.

    5.1.5.2 Differentiate between the data types: Boolean, integer, double, string and date.

    Integer

    Integer data type contains any whole number value that does not have any fractional part.

    Double

    Any number value that may and could contain a fractional part.

    String

    Any value that contains a sequence of characters.

    Boolean

    Boolean type consists either a True or False value. Programmers usually use it to store status.

    5.1.5.3 Differentiate between mathematical and logical (Boolean) operators.

    Function:

    Mathematical operators perform mathematical operations such as plus or substract. Relationaloperators perform element-by-element comparisons between two arrays. Logical operators perform

    logical operations such as checking the condition of two Boolean values.

  • 7/29/2019 LALA5 Programming

    4/6

    CHAPTER FIVE - PROGRAMMING

    42 | P a g e

    Symbols:

    These operators have their own symbols based on the programming language.

    5.1.5.4 Differentiate between sequence control structure and selection control structure.

    ASPECTS SEQUENCE CONTROL SELECTION CONTROL

    Usage

    Use when want to execute codeline by line.

    Does not use the decisionsymbol.

    Use when want to implementdecision making process in theprogram.

    Use the decision symbol.

    Execution FlowExecute statement one by onein linear @ consecutive order.

    Execute different statement fordifferent conditions.

    Flow Chart

    5.2 Program Development

    5.2.1.1 Describe the five main phases in program development:

    problem analysis

    During the problem analysis phase, the programmer will interview the client to find out what theclients needs are.

    program design

    Based on that, the programmer will design a flow chart that represents the needs of the client

    coding

    Once the flow chart is confirmed, the programmer will perform coding.

    testing and debugging

    If there are any errors, the programmer will do a debugging of the program.

    documentation

  • 7/29/2019 LALA5 Programming

    5/6

    CHAPTER FIVE - PROGRAMMING

    43 | P a g e

    After this, the programmer will complete the documentation for the program; this includes the usermanual, a clear layout of the input and output records and a program listing.

    5.2.2.1 Apply program development phases to solve problems.

    PROBLEMS SOLUTIONS

    Users dont understand what they want.Programmers use whiteboards to sketchdata flows of the user or clients system.

    Users wont commit to set of writtenrequirements

    Programmers must ensure that they getthe clients signature of approval for theprogram requirements.

    Users insist on new requirements afterthe cost & schedule have been fixed.

    Programmers must clearly explain thatthey will charge extra costs for anyrequirements not previously specified byusers.

    Communication with users are slow.Programmers must constantly interactwith users or clients.

    Users often do not participate in views

    or are incapable of doing so.

    Programmers should show users some

    samples programs (prototyping).

    5.3 Current and Future Developments

    Find out the latest programming languages:

    fifth generation language

    Fifth generation programming language (5GL) is an advance programming language which

    concentrates on solving problems using constraints given to the program.

    In fifth generation language, the programmer just need to define the problem to be solve and theprogram will automatically code the program based on the problem definition.Fifth generationlanguages are designed to make the computer solve the problem for you. These languages aremostly used in artificial intelligence research. Examples of fifth generation languages include Prologand Mercury.

    natural language

    Natural Language programming aims to use natural language such 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 technicalprogramming knowledge is required to write a program.The programmer needs to define the programusing normal language.

  • 7/29/2019 LALA5 Programming

    6/6

    CHAPTER FIVE - PROGRAMMING

    44 | P a g e

    OpenGL (Graphic Library)

    OpenGL is a standard specification to describe the standard Application Programming Interface (API)for 3D/2D computer graphic applications. Its specification describes a set of functions and the exactbehaviours that the 3D/2D application must perform.

    OpenGL was developed by Silicon Graphics. OpenGL is widely used in virtual reality, scientificvisualisation, flight simulation and video game development