Your SlideShare is downloading. ×
F1001 PROGRAMMING FUNDAMENTALS  UNIT   1INTRODUCTION TOPROGRAMMING Hardware And Software Components Steps Of Program Exe...
F1001 PROGRAMMING FUNDAMENTALSINTRODUCTION TO COMPUTER SYSTEMS•   Computer is an electronic device used to process data.• ...
F1001 PROGRAMMING FUNDAMENTALSEnvironment of Computer System     The four parts of computer system are:    Software- set ...
F1001 PROGRAMMING FUNDAMENTALS        4.   Communication Device                     Allows user to communicate or exchang...
F1001 PROGRAMMING FUNDAMENTALS•   Software development refers to all activities to produce solution of information system ...
F1001 PROGRAMMING FUNDAMENTALS•   Output – Output is raw data that has been processed by the computer (result). Output wil...
F1001 PROGRAMMING FUNDAMENTALS•   Result displayed by a program is called “program output”.•   Example: Cash withdrawal fr...
F1001 PROGRAMMING FUNDAMENTALS•   How Human and Computer Interact:       People communicate with computers using programm...
F1001 PROGRAMMING FUNDAMENTALSEVOLUTION OF PROGRAMMING LANGUAGES     Level5                                        Human L...
F1001 PROGRAMMING FUNDAMENTALS     •   Program Example:                              Instruction to compute 2 * 4 using ma...
F1001 PROGRAMMING FUNDAMENTALS     •   Example of Mnemonic code:                                 Program to compute 2 * 4 ...
F1001 PROGRAMMING FUNDAMENTALS                        ‘BASIC PROGRAM                        ‘AVERAGING THREE INTEGERS     ...
F1001 PROGRAMMING FUNDAMENTALS•   A programming language that resembles human language.•   Known as knowledge-based langua...
F1001 PROGRAMMING FUNDAMENTALSTypes of Translator1.    Assembler      •    Translates the whole program at one time.      ...
F1001 PROGRAMMING FUNDAMENTALS3.    Interpreter      •    Program that translates a high level language to machine languag...
F1001 PROGRAMMING FUNDAMENTALS        Example, LRT-STAR machine (ticket) can be used by anyone.4.   Maintainability     ...
F1001 PROGRAMMING FUNDAMENTALS                            17
Upcoming SlideShare
Loading in...5
×

Unit 1

861

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
861
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
28
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Unit 1"

  1. 1. F1001 PROGRAMMING FUNDAMENTALS UNIT 1INTRODUCTION TOPROGRAMMING Hardware And Software Components Steps Of Program Execution The Evolution Of Programming Language Translator And The Types Of Translator Six Criteria Of A Good Program 1
  2. 2. F1001 PROGRAMMING FUNDAMENTALSINTRODUCTION TO COMPUTER SYSTEMS• Computer is an electronic device used to process data.• Computer system is a group of reference to all computer hardware related including processor, storage devices, input devices, output devices and communication devices. 2
  3. 3. F1001 PROGRAMMING FUNDAMENTALSEnvironment of Computer System The four parts of computer system are: Software- set of computer’s instructions that directs devices to carry out tasks. Hardware – parts of a computer that can be seen and touched. Data – facts arrangement that can be modified by computer into a beneficial form. User – a person who uses the computer.Component Hardware Category• Hardware is parts in computer that can be seen and touched.• The five categories are: 1. Input Device  Input device is an intermediary device that allows user to enter data and instruction to computer’s memory.  Example: Mouse, microphone and keyboard 2. Output Device  It is used to generate information that has been executed by the computer for the user.  Example: printer, monitor and speaker. 3. Storage Device  It is used to store and access data, instructions and information from memory.  Example: Floppy disc drive, CD-ROM drive and DVD-ROM Drive. 3
  4. 4. F1001 PROGRAMMING FUNDAMENTALS 4. Communication Device  Allows user to communicate or exchange data/ information with other users.  Examples: Modem, Fibre Optic, and Coaxial Cable 5. System Unit  System unit is plastic and metal coats containing Centre Processing Unit (CPU), memory and other electronic devices.  CPU, sometimes named as processor, is an electronic device that executes instruction in computer.  Memory is a series of electronic element that holds data and instructions during the period of processing by CPU.Types of Software• Software is a set of computer instructions that directs devices to carry out tasks. The two types of software are: 1. System Software  All programs related to modification and monitoring computer’s operations including operating system (OS), translator and program services. Example: Disk Operating System (DOS) 2. Application Software  Application Software is a program designed to perform task or functions. Example: Word Processing (Microsoft Word) and Spreadsheet Software (Microsoft Excel). 4
  5. 5. F1001 PROGRAMMING FUNDAMENTALS• Software development refers to all activities to produce solution of information system regarding to organisation problem.• The activities are system analysis, system design, programming, testing, conversion and production and also maintenance.DEFINITION OF PROGRAM, PROGRAMMING AND PROGRAMMER• To understand program design in application software, user should know the definitions of:  Program:  A set of step-by-step instructions that directs a computer to perform a specific task and to produce the required results.  Programming:  Programming is a process of designing/ creating a program.  Programmer:  Programmer is a person who writes the program.STEPS OF PROGRAM EXECUTION INPUT (data) OUTPUT (information) PROCESS (processor)• Input – Refers to the process of entering data, program and instructions into the computer system using input devices.• Process – Computer processes raw data into usable information to be used by user. Data processing is done by the CPU (Central Processing Unit). 5
  6. 6. F1001 PROGRAMMING FUNDAMENTALS• Output – Output is raw data that has been processed by the computer (result). Output will be converted to an understandable form before being displayed or printed.• Example: Flow of ATM program  Assume that our transaction is money withdrawal. The instructions are: a. Get the card number from the user (Input) b. Get pin number from the user (Input) c. Process the input data (Process) d. Get the transaction chosen by the user (Input) e. Get the account type from the user (Input) f. Process the transaction as wanted by the user (Process) g. Withdraw amount of money required by the user (Output) h. Print receipt for the user (Output) INPUT OUTPUT PROCESS Input: Example: Card number, ATM pin number, type of transaction, type of account, amount of money to withdraw. Process: Example: Process to identify card number, valid pin number, type of transaction, type of account and deducts the withdrawal from the user’s account. Output: Example: Receipt will show balance in user’s account and money withdrawn.EXECUTING A PROGRAM• To execute a program, CPU will examine each program instruction in memory and send out the required command signals to carry out the instruction.• During execution, data can be entered into memory and manipulated in some specific way (delete and modify) as required.• Program instructions are used to copy a programs data (program input) into memory.• After the input data were processed, instructions for displaying or printing will be executed. 6
  7. 7. F1001 PROGRAMMING FUNDAMENTALS• Result displayed by a program is called “program output”.• Example: Cash withdrawal from ATM machine. Machine language Step 2 program for processing card Central Processing number and PIN number. Unit. Step 1 Input data: Card Number, Data entered during PIN Number, execution. transaction. Step 3 Program Output results: Computed results. Output Receipt and money First step: Data entered by user are stored in memory (input). Second step: CPU will instruct program to process the card number and ATM pin number with the data in memory concurrently. Program will execute the transaction chosen by the user and store the result in memory. Third step: The outputs are money withdrawal and receipt (output).PROGRAMMING LANGUAGE• Definition:  A set of rules and reserved words (keywords) that can be used to tell a computer what are the operations to be done.  Artificial language composed by a fixed vocabulary and set of rules is used to create instructions for the computer to follow.  Now, there are over 200 programming languages in the world. For example: Cobol, Pascal, C, C+ +, and Fortran.• How Human Interact:  Example: People communicate using human languages, such as Bahasa Melayu, English and Japanese. Interaction HUMAN LANGUAGE (BAHASA MELAYU) 7
  8. 8. F1001 PROGRAMMING FUNDAMENTALS• How Human and Computer Interact:  People communicate with computers using programming languages such as C, C++ and Cobol. Interaction PROGRAMMING LANGUAGE (C, C++, COBOL)#include <stdio.h>#include <conio.h>main() Program{ (Aturcara)int a,b,c; /* hold variables value*/int sum; /* variable – to hold total (a+b+c) */ Mengirafloat avg; /* variable output*/ Hasilclrscr(); Purataprintf (“Input three numbers:”); /* ask user to enter 3 numbers*/ Tigascanf (“%d %d %d”, &a, &b, &c);sum = a+b+c; /* calculate total of a, b and c*/ Nomboravg = sum / 3; /* calculate average*/ Dalamprintf (“Average of the numbers: %.2f”, avg); /* Display the average*/ Bahasa C} Example program in C language to calculate average of 3 numbers 8
  9. 9. F1001 PROGRAMMING FUNDAMENTALSEVOLUTION OF PROGRAMMING LANGUAGES Level5 Human Language – 5th Generation4 Very High Level Language – 4th Generation3 High Level Language – 3rd Generation2 Second Generation1 First Generation Year 1960 1970 1980 1990  This figure shows the generations of language based on chronological time factor.  The darker shade indicates the period of greater use by application programmers.  The lighter shade indicates the time which generation faded eventually from its primary use.1. First Generation Language (Machine language (1950-1960)) • The lowest level of language. • It represented data and program instructions as 1s and Os - binary digits corresponding to the on and off electrical states in the computer. Examples: 0 represents “off” and 1 represents “on”. • The only language that the computer could understand (does not require translator). • Machine language is machine-dependent. Meaning, a written program for one computer generally cannot be executed on another. For example, a program written in Apple PC cannot be run in IBM PC. • Advantages: o The most efficient in terms of storage area and speed. o Allows the program to fully utilize the computers potential of data processing. • Disadvantages: o The instruction and syntax in a program is not standardised. It depends on the type of computer used. o Program instruction executes only on the specific machine for which it was written. 9
  10. 10. F1001 PROGRAMMING FUNDAMENTALS • Program Example: Instruction to compute 2 * 4 using machine language2. Second Generation (Assembly Language (1950s) • Known as symbolic language. • It was developed to replace "0" and "1" used in Machine Language. • It uses mnemonic codes - a symbol chosen to help user to remember the significance of the symbol. For example, A represented ADD and S represented SUM • Computer does not understand the language so it needs an assembler to translate the program to machine language. • Advantages: o Program can run faster. o An efficient use of the memory. • Disadvantages: o Errors can be made easily - difficult to identify & correct errors. o It is difficult to understand. o It takes a long duration of time to write the program. 10
  11. 11. F1001 PROGRAMMING FUNDAMENTALS • Example of Mnemonic code: Program to compute 2 * 4 using assembly language3. High Level Language ((3GL, 4GL, 5GL) 1960s till now) • Instruction is written as a series of English-like words. • Translator (Compiler/Interpreter) is needed to translate high level language to machine language. • It is Machine-Independent. The program can be written and executed on any computer. • It can be classified into two categories: i. Non-procedural language A language that states task to be accomplished but does not state the steps needed to accomplish it. ii. Procedural language. A language that represents a step-by-step process (procedure) for solving problem. • Advantage: o Easy to be developed and maintained3rd Generation Language (1960s)• It is called a procedural language.• Translation is done by compiler/ interpreter.• Example: FORTRAN, COBOL and BASIC. 11
  12. 12. F1001 PROGRAMMING FUNDAMENTALS ‘BASIC PROGRAM ‘AVERAGING THREE INTEGERS PRINT “Mengira Purata” PRINT “---------------------“ PRINT “Nilai A = “; 20 PRINT “Nilai B = “; 30 PRINT “Nilai C = “; 40 PRINT “Purata tiga nombor ialah “; (20+30+40)/3 END Program in Basic to compute the average of three numbers4th Generation Language (1980s)• Program is written in English-like statements.• It is a short programming language where the operation needs a few lines instead of hundreds of lines.• It is a non-procedural language.• Known as query language, which can be used to retrieve data from database.• Example: PROLOG, FOCUS, LISP and SQL.• Advantages: o Result-oriented where they emphasize on what instead of how. o It is simpler and easier, so programmers and non-programmers can use this language with minimum training. Create table order ( OWNERID INTEGER NOT NULL, ITEM CHAR (40) NOT NULL); SQL Language5th Generation Language ((Natural Language) 1990s) 12
  13. 13. F1001 PROGRAMMING FUNDAMENTALS• A programming language that resembles human language.• Known as knowledge-based language.• Translates human instructions into code (machine language) where a computer can understand.• The use of a natural language to access knowledge base is called knowledge-based system.• Example: Expert system that stores knowledge of an expert. For example, expertise of a doctor or engineer. Natural LanguageLANGUAGE TRANSLATOR• A translator is a program that:  Checks syntax of a program to ensure the programming language is used correctly, by giving you the syntax-error messages, which is known as diagnostics.  Translates a program into language that the computer can understand.  Produces descriptive error messages known as syntax-error to programmer if there are errors in the programs. Syntax – set of rules to be followed when Syntax Error – error in the use of a programming writing a program, these rules are similar language. to the grammatical rules in English. Example in C: Example: Statement: clrscr() Message displayed on the screen is If semicolon (;) is not placed after statement, a “please enter a number”. message will display: C Language: “Error DIT103.CPP: Declaration syntax- printf(“please enter a number”); error” The correct syntax is: clrscr(); 13
  14. 14. F1001 PROGRAMMING FUNDAMENTALSTypes of Translator1. Assembler • Translates the whole program at one time. • Also called assembler program. • A program, which is used to convert assembly language to machine language. sseg segment stack db 256 11101 100000 100000 dup (?) 11110 10111000 sseg ends 11101000 dseg segment Assembler 11111100 data db “2 x 4 = ” 10111000 dseg ends 10001110 11011000 cseg segment 10111000 assume 10001110 11000000 cs:cseg:ds:sdeg:ss:sseg. es:nothing Start proc far Machine Language Assembly Language2. Compiler • Translate the whole program at one time. • Translates the source code, for example COBOL language to machine language. # • Used to translate C, COBOL and other language. include <stdio.h> main( ) 11101 100000 100000 { 11110 int x, y, z, sum; 10111000 double avg; Compiler 11101000 11111100 printf(" Enter 3 numbers:"); 10111000 scanf("%d %d %d",&x, &y, &z); 10001110 11011000 sum = x + y + z; 10111000 avg = sum / 3; 10001110 11000000 printf("x = %d y = %d z = %d ", x, y, z); printf("the average is = %f",avg); return 0; Machine Langeage } 14 C Language
  15. 15. F1001 PROGRAMMING FUNDAMENTALS3. Interpreter • Program that translates a high level language to machine language. • It translates one line at a time and executes each line after it is translated. • Displays feedback as the error occurred. • Used to translate BASIC and SQL language. ‘BASIC PROGRAM 10001110 11000000 ‘AVERAGING THREE INTEGERS 10111010 PRINT “Mengira Purata” 10111011 PRINT “---------------------“ 10001101 110110 PRINT “Nilai A = “; 20 10111111 PRINT “Nilai B = “; 30 Interperter 10110000 000000010 PRINT “Nilai C = “; 40 10110011 000001000 PRINT “Purata tiga nombor ialah “; 11100011 111111000 (20+30+40)/3 00001110 110000 END 10100000 10111001 10100100 Basic Language Machine LanguageCRITERIA OF A GOOD PROGRAM• A good program is a program that has fulfils the following criteria’s: 1. Accuracy  Program that fulfils all the specifications, requirements and objectives.  For example: ATM machine. When a user withdraws RM200, the user will get RM200 in cash.  To ensure accuracy, programmer needs to define a control to prevent invalid value. 2. Reliability  No errors. Produces output as required.  Information is reliable if the user can depends on its accuracy and completeness.  Example: the balance in Touch N Go card. 3. Usability  Easy to use and learn. Programmer or non-programmer can use the interaction. 15
  16. 16. F1001 PROGRAMMING FUNDAMENTALS  Example, LRT-STAR machine (ticket) can be used by anyone.4. Maintainability  A program that is easily understood, tested and modified without having to change the whole program. The program may be changed by any programmers at anytime to fulfil the current requirement.  Example: Total digit of telephone number can be changed from 7 to 8 digits without changing the existing application program.5. Efficiency  Fast program execution and quick access to data to generate output.  Example: Tickets System in LRT-STAR System6. Readability  A readability program is:  A clear and understandable program.  Using meaningful name for variables.  Have explanations on the program’s function.  Instruction is written by using spacing in between words.  Example of a readable program: /* compute total of 2 numbers*/ printf (“Enter first numbern”); scanf (“%d”, &number1); printf (“Enter second numbern”); scanf (“%d”, &number2); total = number1 + number2; printf (“Total is %dn”, total); 16
  17. 17. F1001 PROGRAMMING FUNDAMENTALS 17

×