Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unit# 8: Introduction to Computer Programming

Similar presentations


Presentation on theme: "Unit# 8: Introduction to Computer Programming"— Presentation transcript:

1 Unit# 8: Introduction to Computer Programming

2 Learning Objectives In this unit you will be learn about:
Computer program Types of languages (low & high level) Editor, Translator (compiler & interpreter) IDE Source program, object program Principles of structured and modular programming

3 Computer program A computer program is a collection of instructions that performs a specific task when executed by a computer. A computer requires programs to function and typically executes the program's instructions in a central processing unit. Series of instructions to a computer to accomplish a task Instructions must be written in a way the computer can understand

4 Types of languages Programming Language:
A programming language is a special language programmers use to develop software programs, scripts, or other sets of instructions for computers to execute. Three types of programming languages: Machine language Assembly language High-level language

5 Machine Language Only language of a computer understood by it without using a translation program Normally written as strings of binary 1s and 0s Written using decimal digits if the circuitry of the computer being used permits this

6 Machine Language A Typical Machine Language Instruction Format

7 Machine Language A Sample Machine Language Program

8 Machine Language Advantages & Limitations of Machine Language:
Can be executed very fast Limitations Machine Dependent Difficult to program Error prone Difficult to modify

9 Assembly/Symbolic Language
Programming language that overcomes the limitations of machine language programming by: Using alphanumeric mnemonic codes instead of numeric codes for the instructions in the instruction set e.g. using ADD instead of 1110 (binary) or 14 (decimal) for instruction to add Allowing storage locations to be represented in form of alphanumeric addresses instead of numeric addresses e.g. representing memory locations 1000, 1001, and 1002 as FRST, SCND, and ANSR respectively Providing pseudo-instructions that are used for instructing the system how we want the program to be assembled inside the computer’s memory e.g. START PROGRAM AT 0000; SET ASIDE AN ADRESS FOR FRST

10 An Example of Assembly Language Program

11 Advantages of Assembly Language Over Machine Language
Easier to understand and use Easier to locate and correct errors Easier to modify No worry about addresses Easily reloadable Efficiency of machine language

12 Limitations of Assembly Language
Machine dependent Knowledge of hardware required Machine level coding Typical Uses of Assembly Language: Mainly used today to fine-tune important parts of programs written in a high-level language to improve the program’s execution efficiency

13 High--Level Languages
Machine independent Do not require programmers to know anything about the internal structure of computer on which high-level language programs will be executed Deal with high-level coding, enabling the programmers to write instructions using English words and familiar mathematical symbols and expressions

14 Advantages of High--Level Languages
Machine independent Easier to learn and use Fewer errors during program development Lower program preparation cost Better documentation Easier to maintain

15 Editor A source code editor is a text editor program designed specifically for editing source code of computer programs by programmers. It may be a standalone application or it may be built into an integrated development environment (IDE) or web browser.

16 Editor Concepts Editing a file is to modify the content of a file
Text editor: Enter and modify text in a text file Word processor: Enter, modify and format text in a document Line editor: Edit file one line at a time Unix examples: ex, ed and sed Full screen editor Shows a whole screen of text at a time

17 Editor features enter text search and replace copy, cut and paste
undo and redo importing and exporting text save and cancel Types of editors: EMACS Editor PICO AND NANO EDITORS GUI Editors

18 Translator A translator is a computer program that performs the translation of a program written in a given programming language into a functionally equivalent program in a different computer language, without losing the functional or logical structure of the original code. Types: Assembler Compiler Interpreter

19 Assembler Software that translates as assembly language program into an equivalent machine language program of a computer.

20 Compiler Translator program (software) that translates a high-level language program into its equivalent machine language program Compiles a set of machine language instructions for every program instruction in a high-level language

21 Interpreter Interpreter is a high-level language translator
Takes one statement of a high-level language program, translates it into machine language instructions A program that can translate and execute a program line by line. Immediately executes the resulting machine language instructions Compiler simply translates the entire source program into an object program and is not involved in its execution

22 Program Errors Syntax Errors: Runtime error: Logical errors:
Errors in grammar of the language Runtime error: When there are no syntax errors, but the program can’t complete execution Divide by zero Invalid input data Logical errors: The program completes execution, but delivers incorrect results Incorrect usage of parentheses

23 Integrated Development Environment (IDE)
An integrated development environment (IDE) is a software suite that consolidates the basic tools developers need to write and test software. An integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of a source code editor, build automation tools and a debugger. 

24 Source Program Source code is the fundamental component of a computer program that is created by a programmer. A program written in a high-level language is called source code. Source code is also called source program. Computer cannot understand the statements of high-level language. The source code cannot be executed by computer directly. It is converted into object code and then executed.  

25 Object Program A program in machine language is called objet code. It is also called object program or machine code. Computer understands object code directly.

26 Difference between source code and objet code
1. Source code is written in high-level or assembly language. 2. Source code is easy to understand. 3. Source code is easy to modify. 4. Source code contains fewer statements than object code. Object code 1. Object code is written in machine language through compilers. 2. Object code is difficult to understand. 3. Object code is difficult to modify. 4. Object code contains more statements than source code.

27 Principles of structured and modular programming
Structured programming is the set of design and implementation processes that yield well-structured programs. A disciplined approach to programming Top-down design Step-wise refinement using a restricted set* of program structures * The set of program structures used in structured programming is: Sequence Choice Loop

28 Top-Down Design A program is divided into a main module and its related modules. Each module is in turn divided into sub modules until the resulting modules are understood without further division.

29 Modular Programming Determine the major tasks that the program must accomplish. Each of these tasks will be a module. Some modules will be complex themselves, and they will be broken into sub-modules, and those sub-modules may also be broken into even smaller modules.


Download ppt "Unit# 8: Introduction to Computer Programming"

Similar presentations


Ads by Google