OVERVIEW OF COMPUTER AND PROGRAMMING 1 1 Computer











































- Slides: 43

OVERVIEW OF COMPUTER AND PROGRAMMING 1. 1 Computer Components and Operations 1. 2 Steps Involved in the Programming Process 1. 3 Interactive Input 1. 4 Data Hierarchy and File Input 1. 5 Flowchart Symbols and Pseudocode Statements 1. 6 Name Variables, Assign values to Variables 1. 7 Sentinel, or Dummy Value to End Program 1. 8 Manage Large Flowchart 1. 9 Data Types, the Evolution of Programming Techniques

1. 1 COMPUTER COMPONENTS AND OPERATIONS COMPONENTS Hardware equipment / device Software instructions that tell the computer what to do written by programmers. 2 types � System software � Eg: OS, Windows, DOS, Unix Application software Eg: Adobe, Ms Office, Games, etc

1. 1 COMPUTER COMPONENTS AND OPERATIONS (CONT…) OPERATIONS 1. Input 2. CPU (Central Processing Unit) PROCESS Output 4. INPUT Processing 3. keyboard, mice, data printer, monitor, information Storage magnetic disks, tapes, compact discs, flash media OUTPUT

1. 1 COMPUTER COMPONENTS AND OPERATIONS (CONT…) Programming language � Eg: Visual basic, C, C++, Java, COBOL Machine language � Binary form – 0, 1 Compiler / interpreter � The language translation software that convert a programmer’s statement to binary form Storage � Internal storage – RAM (volatile) � External storage – floppy disk, hard media (permanent) Language � Rules disk, flash syntax governing its word usage and punctuation.

1. 1 COMPUTER COMPONENTS AND OPERATIONS (CONT…) TWO TRUTH AND A LIE 1. Application software comprises the programs FALSE that you use to manage your computer such as operating systems 2. Data includes all the text, numbers and other information that are processed by a computers TRUE 3. Programming languages have rules governing word usage and punctuation; these TRUE rules are called the language’s syntax.

1. 2 STEPS INVOLVED IN THE PROGRAMMING PROCESS Six Programming Steps 1. 2. 3. 4. 5. 6. Understanding the problem Planning the logic Coding the program Using software to translate the program into machine language Testing the program Putting the program into production

1. 2 STEPS INVOLVED IN THE PROGRAMMING PROCESS (CONT…) 1. UNDERSTANDING THE PROBLEM � Understand the whole problem � Programmer ask user, what they need � Difficult aspects of programming � Example : �Sistem pendaftaran pelajar �Programmer ask staff management, what they want in the system • • • NAME NO MATRIK NO KP ADDRESS. NO PHONE

1. 2 STEPS INVOLVED IN THE PROGRAMMING PROCESS (CONT…) 2. PLANNING THE LOGIC � Programmer plan the steps of the program � Planning tools • Pseudocode • flowchart � Doesn’t worry about syntax � Sequence of events (input / output) � Desk checking Program’s logic on paper before write the program.

1. 2 STEPS INVOLVED IN THE PROGRAMMING PROCESS (CONT…) 3. CODING THE PROGRAM Convert the logic (pseudocode/flowchart) into programming � Use Programming language (C, C++, Java, etc) � Input operations Arithmetic processing Output operations Other standard functions Using the corrects syntax � CODING � Writing the statements in a programming language.

1. 2 STEPS INVOLVED IN THE PROGRAMMING PROCESS (CONT…) 4. USING SOFTWARE TO TRANSLATE THE PROGRAM INTO MACHINE LANGUAGE � Computer understand – machine language(binary number – 0, 1) � Translator / Compiler / Interpreter Change English-like high-level programming language in which programmer writes into the low-level machine language that the computer understands. � Syntax error Error in language and grammar

1. 2 STEPS INVOLVED IN THE PROGRAMMING PROCESS (CONT…) 5. TESTING THE PROGRAM � Free from logical error Incorrect instruction are performed or Instructions are performed in the wrong order 6. PUTTING THE PROGRAM INTO PRODUCTION � Ready for the organization to use.

1. 2 STEPS INVOLVED IN THE PROGRAMMING PROCESS (CONT…) ANALISA & MEMBENTUK ALGORITMA SPESIFIKASI MASALAH /KEPERLUAN MENULIS ATURCARA (PENGATUCARAAN) PENGATURCARA MENGUJI & MENYAHRALAT (TESTING & DEBUGGING) LARIAN ATURCARA YANG TELAH DIBANGUNKAN

1. 2 STEPS INVOLVED IN THE PROGRAMMING PROCESS (CONT…) TWO TRUTH AND A LIE 1. Understanding the programming problem may TRUE be one of the most difficult aspects of programming 2. The two most commonly used logic-planning tools are flowchart and pseudocode 3. Flowcharting a program is a very different process if you will be using an older programming language instead of a newer one. TRUE FALSE

1. 3 INTERACTIVE INPUT Data values entered from a keyboard Prompt – message displayed on a monitor, asking the user for a response Command prompt – (computer’s OS using text) GUI – graphical environment

1. 3 INTERACTIVE INPUT (CONT…) Command Line Environment GUI Environment

1. 3 INTERACTIVE INPUT (CONT…) TWO TRUTH AND A LIE 1. A prompt is a message that is displayed on a monitor, asking the user for a response. TRUE 2. The command prompt allows users to interact with a program in a graphical nontext FALSE environment. 3. The logic for a command line interactive program and a GUI interactive program basically the same. TRUE

1. 4 DATA HIERARCHY AND FILE INPUT o o o Eg: list thousands of people (personnel, student) Field – single data item (eg: name, address, salary) Records – groups of fileds (eg: Student record – No. Matrik, Grade) Files – groups of records (eg: Students in your class) Database - groups of files (tables) Queries – related data items.

1. 4 DATA HIERARCHY AND FILE INPUT C ( ONT…) BIODATA PENSYARAH BIODATA PELAJAR Bil Nama k/p Tel Bil PENGINAPAN PELAJAR Nama K/P GAJI PENSYARAH Alamat Asrama K/P Gaji File RESULT PELAJAR Nama K/P Tel Record MAKLUMAT KELUARGA PNGK Nama Field Bil Anak Alamat Tel

1. 4 DATA HIERARCHY AND FILE INPUT C ( ONT…) TWO TRUTH AND A LIE 1. In the data hierarchy, a field is a single data item, such as lastname, streetaddress or salary. 2. In the data hierarchy, fields are grouped together to form a record; record are groups of fields that go together for some logical reason. 3. In the data hierarchy, related records are grouped together to form a field. TRUE FALSE

LATIHAN (1. 1 – 1. 4) 1. 2. 3. 4. 5. 6. Nyatakan empat (4) operasi komputer Senaraikan enam (6) proses pengaturcaraan Berikan tiga (3) contoh bahasa pengaturcaraan Apakah tugas “Programmer”? Terangkan secara ringkas fasa ke-2 dalam proses pengaturcaraan. Terangkan secara ringkas maksud ungkapan di bawah: a) b) c) d) e) f) g) h) i) Prompt Machine language Command prompt Logical error Syntax Software Desk-checking Compiler coding

1. 5 FLOWCHART SYMBOLS AND PSEUDOCODE STATEMENTS FLOWCHART Pictorial representation of the logical steps it takes to solve a problem. PSEUDOCODE English-like representation of the same thing. WRITING PSEUDOCODE

1. 5 FLOWCHART SYMBOL AND PSEUDOCODE STATEMENTS (CONT…) Pseudocode Not final product Flexible Example Start/stop begin/end Input my. Number get my. Number read my. Number set my. Answer = my. Number * 2 calculate my. Answer = my. Number times 2 compute my. Answer as my. Number doubled my. Answer = my. Number * 2 Output my. Answer display my. Answer write my. Answer print my. Answer

1. 5 FLOWCHART SYMBOL AND PSEUDOCODE STATEMENTS (CONT…) DRAWING FLOWCHARTS • Parallelogram - input symbol • Rectangle - processing symbol • Parallelogram - output symbol • Arrow / Flowlines - Connect the steps • Terminal symbols - Start / Stop

1. 5 FLOWCHART SYMBOL AND PSEUDOCODE STATEMENTS (CONT…) Flowchart and pseudocode of program that doubles a number

1. 5 FLOWCHART SYMBOL AND PSEUDOCODE STATEMENTS (CONT…) After developed flowchart or pseudocode 1. 2. 3. 4. 5. 6. 7. 8. 9. Buy a computer Buy a language compiler Learn a programming language Code the program Attempt to compile it Fix the syntax error Compile it again Test with several sets of data Put into production

1. 5 FLOWCHART SYMBOL AND PSEUDOCODE STATEMENTS (CONT…)

1. 5 FLOWCHART SYMBOL AND PSEUDOCODE STATEMENTS (CONT…)

1. 6 NAME VARIABLES, ASSIGN VALUES TO VARIABLES / IDENTIFIER � Name memory location. Eg: my. Number calculated. Answer 2 4 4 8 5 10 RULES FOR NAMING VARIABLES. 1. Must be one word (no space) 2. Cannot used any symbol (eg: > + ) & $ @ #. ? ) 3. Some appropriate meaning 4. Cannot start with number

1. 6 NAME VARIABLES, ASSIGN VALUES TO VARIABLES(CONT…) Suggested Variable Names for Pelajar’s Comments nama. Pelajar Good nama. Pljr Good npljr Legal – but cryptic nama. Pelajar. Kolej. Shahputra Legal – but awkward nama pelajar Not legal – embedded space Nama_pelajar Legal namapelajar Legal – but hard to read without camel casing nama+Pelajar Not legal – symbol ‘+’ Nama 2_pljr Legal 2_nama. Pljr Not legal – start with number _2 nama. Pljr Legal

1. 6 NAME VARIABLES, ASSIGN VALUES TO VARIABLES(CONT…) ASSIGNMENT STATEMENTS Eg: calculated. Answer = input. Number*2 luas. Segiempat = panjang * lebar kuasa_3 = nom * nom purata = (Uj 1+Uj 2+Uj 3)/3 punca = b*b – (4*a*c) Assignment operator Equal sign �Left side – name the location where the result will be stored � Rules of precedence �Eg d = a + b * c d = (a + b) * c

1. 6 NAME VARIABLES, ASSIGN VALUES TO VARIABLES(CONT…) 1. The equal assignment operator always requires the name of a memory location on its right side. FALSE 2. Variable names are easier to remember than memory addresses. TRUE 3. A variable name is also called an identifier. TRUE 4. Variable names must be one word, without TRUE spaces 5. As a programmer, you choose specific FALSE memory addresses for your variables.

LATIHAN Bina pseudocode utk soalan 1 dan 2, Bina cartalir utk soalan 3 dan 4. 1. 2. 3. 4. Mengira luas segitiga Mencari kuasa 4 bagi nombor yang dimasukkan Mengira isipadu sfera isipadu = 4/3 � j 3 Mengira gaji Gaji = (jam * 5. 00) + bonus + elaun

1. 7 SENTINEL, OR DUMMY VALUE TO END PROGRAM Infinite loop Repeating flow of logic with no end Making decision Testing a value Use decision symbol (diamond shape) Dummy value / Sentinel value Preselected value that stops the execution of a program eof end-of-file

1. 7 SENTINEL, OR DUMMY VALUE TO END PROGRAM (CONT…) Program with sentinel value of 0 Flowchart using eof Start get No No = 0? Stop eof? Ans = No * 2 print Ans Stop

1. 7 SENTINEL, OR DUMMY VALUE TO END PROGRAM (CONT…) TWO TRUTH AND A LIE 1. A program that contains an infinite loop is one that never ends. TRUE 2. A preselected value that stops the execution of a program is often called a dummy value or a sentinel value. TRUE 3. Many programming languages use the term fe (for “file end”) to talk about a marker that automatically acts as a sentinel. FALSE

1. 8 MANAGE LARGE FLOWCHART on-page connector symbol Circle off-page connector symbol Square with pointed bottom

1. 8 MANAGE LARGE FLOWCHART (CONT…) Flowchart using the connector start 1 Step 1 Step 1 1 p. 2 A

1. 8 MANAGE LARGE FLOWCHART (CONT…) TWO TRUTH AND A LIE 1. You can use a connector when limited page size forces you to continue a flowchart in an unconnected location or on another page. TRUE 2. By convention, programmers use a parallelogram as an on-page connector symbol. TRUE 3. By convention, programmers use a symbol that look like a square with a pointed bottom as an off-page connector symbol. FALSE

1. 9 DATA TYPES, THE EVOLUTION OF PROGRAMMING TECHNIQUE DATA TYPES Text String constant / text constant String variable / text variable Constant – value doesn’t change Numeric constant Numeric variable • Integer • Floating-point (fractional) Variable– value can change

1. 9 DATA TYPES, THE EVOLUTION OF PROGRAMMING TECHNIQUES (CONT…) Example: Bil Nama No. KP PNG Jantina Kolej Gred Byrn 1 Farah 111222333 3. 45 P Sputra A 45. 00 2 Mamat 666444777 2. 99 L IKIP B 23. 45 3 Isa 333555888 2. 45 L PSDC C 56. 50 4 Sofea 444999222 3. 90 P Sputra A 44. 40 • • Numeric Integer – Bil, No. KP Numeric Floating point – PNG, Byrn Text string – Nama, Kolej Text char – Jantina, Gred Variable • • Numeric Integer - Markah = 90 Numeric Floating point – PIE = 3. 142 Text string – Nama = “Siti” Text char – Gred = “E” Constant

1. 9 DATA TYPES, THE EVOLUTION OF PROGRAMMING TECHNIQUES (CONT…) Example: � Luas. S 4 = Panjang * Lebar Numeric Integer – Luas. S 4, Panjang, Lebar � Luas. S 3 = 0. 5 * Tapak * Tinggi Numeric Integer – Tapak, Tinggi Numeric floating point – Luas. S 3 � Gaji = (jam * 5. 50) + elaun + Bonus Numeric floating point – Gaji, elaun, Bonus, jam � If Markah >= 80 Gred = ‘A’ Numeric Integer – Markah Text char – Gred

1. 9 DATA TYPES, THE EVOLUTION OF PROGRAMMING TECHNIQUES (CONT…) EVOLUTION OF PROGRAMMING TECHNIQUES Procedural programming Focuses on the procedure (programmers create) Input Proses Output Object-oriented programming Focuses on objects or “thing” Describe features, attributes, behaviors DDC 1023 – focuses on procedural programming techniques.

1. 9 DATA TYPES, THE EVOLUTION OF PROGRAMMING TECHNIQUES (CONT…) 1. A Variable’s data type describes the kind of values the variable can hold and the types of operations that can be performed with it. 2. If name is a string variable, then the statement name=“Ed” is valid. 3. If salary is a numeric variable, then the statement salary=“ 12. 50” is valid. TRUE FALSE 4. Procedural programmers focus on actions that are carried out by a program. TRUE 5. Object-oriented programmers focus on a program’s objects and their attributes and behaviors. TRUE