Nota ICT Ting.

5 - CHAPTER 5
/

CHAPTER FIVE - PROGRAMMING

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 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.

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 computer¶s microprocessor.

BASIC.1. Machine language statements are written in binary code. Assembly language is the human-readable notation for the machine language used to control specific computer operations. 3GL. 5. COBOL. or 1GL. High-level programming languages make complex programming simpler and easier to read. Machine language is a set of instructions and data that a computer's central processing unit can execute directly. to write instructions.Programs written in a high-level programming language must be translated into machine language by a compiler or interpreter. An assembly language programmer writes instructions using symbolic instruction codes that are meaningful abbreviations or mnemonics.FIRST GENERATION OF PROGRAMMING LANGUAGE The first generation of programming language. and each statement corresponds to one machine action. THIRD GENERATION PROGRAMMING LANGUAGE The third generation of programming language. write and maintain. A high-level programming language is a programming language that is more abstract. SECOND GENERATION PROGRAMMING LANGUAGE The second generation programming language. Since assembly language consist of human-readable abbreviations. C and C++ are examples of third generation programming languages. .2 Identify the generations of high-level programming languages with examples. the assembler must first convert assembly language into machine-readable language before the computer can readily understand its instructions. that are closer to human language. and more portable across platforms.2. is assembly language. FORTRAN. easier to use. PASCAL. or 2GL. is machine language. or procedural language uses a series of English-like words. An assembler is a program that translates assembly language into machine language.

they simply take dictation. FIFTH GENERATION PROGRAMMING LANGUAGE The fifth generation programming language or visual programming language. NOMAD and FOCUS are examples of fourth generation programming languages.PROGRAMMING 40 Page A very high-level programming language is often referred to as goal-oriented programming language because it is usually limited to a very specific application and it might use syntax that is never used in other programming languages. called a visual programming environment. for creating source codes. is also known as natural language. People can talk to computers and the voice recognition systems can convert spoken sounds into written words. SQL. Prolog and Mercury are the best known fifth-generation languages.1 Define structured approach in programming. STRUCTURED PROGRAMMING EDUCATION . 5. enables users to access data in a database. CHAPTER FIVE .FOURTH GENERATION PROGRAMMING LANGUAGE The fourth generation programming language or non-procedural language.1. but these systems do not understand what they are writing. often abbreviated as 4GL.3. Fifth generation programming allows people to interact with computers without needing any specialised knowledge. Provides a visual or graphical interface.

1. ASSEMBLER An assembler is a computer program for translating assembly language ² essentially.Structured programming often uses a top-down design model where developers map out the overall program structure into separate subsections from top to bottom. y Structured programming often uses a top-down design model.1 Describe the translation method of programming using assembler. In an object-oriented program.4. 5.2 Define object-oriented approach in programming. . A program may have a module or several modules. Examples of structured programming languages include Ada.3 Differentiate between structured approach and object-oriented approach in programming.3. 5. Pascal and Fortran.3. Java.1. interpreter and compiler. One of the earliest OOP languages is Smalltalk. Structured programming is beneficial for organising and coding computer programs which employ a hierarchy of modules. a mnemonic representation of machine language ² into machine language. A top-down design means that the whole program is broken down into smaller sections that are known as modules.1. In the top-down design model. This means that control is passed downwards only through the hierarchy. Visual Basic and C++ are examples of popular OOP languages. the object have relationships with one another. programs are drawn as rectangles. The object-oriented programming approach uses objects. The object-oriented approach refers to a special type of programming approach that combines data with functions to create objects. 5.

Logo and Smalltalk. The interpreter will read each codes converts it to machine code and executes it line by line until the end of the program. When a user wants to run the program. 5. If the compiler encounters any errors. Constants Variables Characteristics Value is not changeable during the course of the program.1.5. Example of assemblers are MACRO-80 Assembler and Microsoft MASM. Pascal and COBOL used compilers as their translators. Several programming languages like C++. it records them in the program-listing file. the object program is loaded into the memory of the computer and the program instructions begin executing. A compiled code generally runs faster than programs based on interpreted language.PROGRAMMING INTERPRETER Interpreter is used to interpret and execute program directly from its source without compiling it first. CHAPTER FIVE .1 Differentiate between constants and variables. the assembly language for the ¶no operation¶ command is NOP and its machine code representation is 10010000. Examples of interpreter-based language are BASIC.For example in intel 80836. . The source code of an interpreted language is interpreted and executed in real time when the user execute it. COMPILER The source code (in text format) will be converted into machine code which is a file consisting of binary machine code that can be executed on a computer.

5.1. Double Any number value that may and could contain a fractional part. integer. Use variable to store data that may or will change during the running of the program.1. Integer Integer data type contains any whole number value that does not have any fractional part. double. 5. Function: . Boolean Boolean type consists either a True or False value.Value can be changed anytime during the course of the program. Usage Use constant when you want to declare someting that won¶t be changed midway in your program execution. String Any value that contains a sequence of characters. Programmers usually use it to store status.5. string and date.3 Differentiate between mathematical and logical (Boolean) operators.2 Differentiate between the data types: Boolean.5.

ASPECTS SEQUENCE CONTROL SELECTION CONTROL Usage y Use when want to execute code line by line. CHAPTER FIVE .Mathematical operators perform mathematical operations such as plus or substract.PROGRAMMING Symbols: These operators have their own symbols based on the programming language. 5. Use when want to implement decision making process in the program.4 Differentiate between sequence control structure and selection control structure.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 the client¶s needs are. Logical operators perform logical operations such as checking the condition of two Boolean values.1. Use the decision symbol. Relational operators perform element-by-element comparisons between two arrays. Flow Chart 5.1.2.2 Program Development 5. Execution Flow Execute statement one by one in linear @ consecutive order. Does not use the decision symbol. Execute different statement for different conditions.5.

‡ testing and debugging If there are any errors. the programmer will design a flow chart that represents the needs of the client ‡ coding Once the flow chart is confirmed.‡ program design Based on that. ‡ documentation . the programmer will do a debugging of the program. the programmer will perform coding.