Free Essay

S.Comp

In:

Submitted By hazmi95
Words 1038
Pages 5
8.0 PROGRAMMING 8.1.1 Definition Program : Programming Language:

8.1 Introduction to Programming

Prepared by : Pn. Marzita Ismail (SC Unit)

a series of instructions that directs a computer to perform tasks. A set of words, abbreviations, and symbol that enables a programmer to communicate instructions to a computer Eg: Java, C++, Fortran, Cobol, C 8.1.2 Types of Programming Language:

1) Low Level Programming Language
• • Why Low Level? : Because it is designed closer to the hardware Machine Language (1st Generation) Assembly Language (2nd Generation) Made up of instructions written in binary code (0 and 1). • Written in mnemonics, more English-like code; codes shorter than The only language that is directly understood by the machine languages computer. Does not need any translator program. • Need to be translated by assembler into machine language before it can be executed by the computer. Machine dependent (written for particular • Machine dependent (written for particular computer and has computer and has to be changed for using on a

Describe/what is/ explain/characteristic



different computer).
Example of coding

to be changed for using on a different computer).

Advantages





Execution speed is very fast. (It does not require any translation because machine language is directly understood by CPU) Translation free (Computer understands only the machine language) Program written in machine language are very lengthy Machine dependent (program is written for particular computer and has to be changed for using on a different computer)





Easy to understand and use: Assembly language use mnemonics instead of using numerical opcodes and memory locations used in machine language. Assembly programs run much faster and use less memory

Disadvantages

• •

• •

Long and tedious to write: requires a higher skill of programming language Machine Dependent (program is written for particular computer and has to be changed for using on a different computer)

2) High Level Programming Language (3rd Generation)
Describe/what is/ explain/characteristic Types & Examples • • • • • • • • • • Why High Level? : Because it is designed closer to human language Portable and machine independent (can run on many different types of computer and operating system) instructions are quite English-like so it is easier to learn than machine or assembly language needs to be translated into machine language that is done by a compiler or an interpreter Structured Language : C, ADA, Pascal Object-oriented Language : Java, C++, Visual Basic Functional Language : LISP, Mathematica Portable or machine Independent (can run on many different types of computer and operating system) Programmer-friendly because it is easier to write, read, and maintain Not as efficient as low- level languages Programs generally run slower because it need to be translated or compiled Low Level Programming Language High Level Programming Language (3rd Generation) • Machine dependent (runs only on one type of computer) • Machine independent (run on different types of computers • Difficult to learn and use and operating system) • Need assembler to be understood by a computer • Easier to learn because instruction used are quite English-like • Need compiler or interpreter to be understood by a computer

Advantages Disadvantages Differences:

8.1.3 Programming Language Paradigm Definition is an approach to solve programming problems. Paradigm Structured Programming Describe/what is/ • Program is divided into modules like function, subroutine and explain/characteristic procedure • Program execution involves changing the memory contents of the computer continuously. • tend to run much faster than other types of program. Examples

Object-oriented Programming

• •

consists of objects which communicate with each other by sending messages Objects are combination of both data and the function into a single unit Java C# Smalltalk
Conceptual simplicity Models computation better Increased productivity. Can have a steep learning curve, initially ( in the beginning) Doing Input / Output can be complicated

• • •
• • • • • •

C FORTRAN, COBOL low memory utilization relatively efficient the most common form of programming in use today. difficulty of reasoning about programs difficulty of parallelization. relatively low level

• • •
• • • • •

Advantages

Disadvantages

8.1.4 Translator Definition/What is/Describe



Types Function



Translate a computer program written in one language (source code) into machine code (translator’s object code) which can be executed by a computer # Note: o Source code ? - Code written in the original form o Object code? - Code in executable form (machine code) Assembler Compiler Interpreter Translates assembly language into • Translates a high-level languages source • Translates a high-level language source machine code. code into machine code as a whole. code into machine code line by line • Scans the entire program first and translates it into machine code to be executed. Slow for debugging Execution time is less • • • Translates and execute the program line by line Good for fast debugging Execution time is more

Differences

• •
Examples
• •

• • # • • •

Debugging??? - removal of mistakes/error from a program


Notes:

GAS - the GNU Assembler MASM - Microsoft Macro Assembler NASM - Netwide Assembler

Java COBOL C++

• • •

BASIC FORTH LOGO

Problem Solving Process

8.2 Approach in problem Solving • Programmer use problem-solving process to create a computer program Steps 1. Analyze the problem Purpose/Why/What 1. To determine the goal of solving the problem which is known as output. 2. To determine the information needs to achieve the goal which is known as input. 3. To determine the processing item. Tools/Techniques • IPO analysis /IPO chart. Function: • To organize and summarize the results of a problem analysis. • To show the Input, Process and Output of the problem. Example Problem statement: Calculate the area of a rectangle. IPO Analysis: Input Process Output IPO Chart: Input length width Processing area = length x width Output area : length, width : area = length x width : area

2. Plan the algorithm

Algorithm? • A number of steps arranged in order to solve a problem. • A step-by-step instructions that will transform the input into the output



Pseudo Code • Informal language used to develop algorithms. • Similar to everyday English.

Problem statement: Calculate the area of a rectangle.



Pseudo Code start read length , width area = length*width print area stop



Flow Chart • Graphical representation of an algorithm. • Special-purpose symbols connected by arrows (flow lines). • Symbols used, name and function:



Flow Chart

Terminator indicates the beginning and end points of an algorithm

Process shows a process/an operation other than input, output or selection

Input-Output shows an input or output operation

Flow Lines indicates the logical sequence of execution steps in the algorithm

Similar Documents