OVERVIEW OF COMPUTER AND PROGRAMMING
1.1 Computer Components and Operations1.2 Steps Involved in the Programming Process1.3 Interactive Input1.4 Data Hierarchy and File Input1.5 Flowchart Symbols and Pseudocode Statements1.6 Name Variables, Assign values to Variables1.7 Sentinel, or Dummy Value to End Program1.8 Manage Large Flowchart1.9 Data Types, the Evolution of Programming Techniques
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
OPERATIONS1. Input
keyboard, mice, data2. Processing
CPU (Central Processing Unit)3. Output
printer, monitor, information 4. Storage
magnetic disks, tapes, compact discs, flash media
1.1 COMPUTER COMPONENTS AND OPERATIONS (CONT…)
PROCESS
INPUT
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 disk, flash
media (permanent) Language syntax
Rules governing its word usage and punctuation.
1.1 COMPUTER COMPONENTS AND OPERATIONS (CONT…)
TRUE
FALSE
TRUE
TWO TRUTH AND A LIE1. Application software comprises the
programs 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
3. Programming languages have rules governing word usage and punctuation; these rules are called the language’s syntax.
1.2 STEPS INVOLVED IN THE PROGRAMMING
PROCESS Six Programming Steps
1. Understanding the problem2. Planning the logic3. Coding the program4. Using software to translate the
program into machine language5. Testing the program6. Putting the program into production
1. UNDERSTANDING THE PROBLEMUnderstand the whole problemProgrammer ask user, what they needDifficult aspects of programmingExample :
Sistem pendaftaran pelajarProgrammer 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 LOGICProgrammer plan the steps of the programPlanning tools
• Pseudocode• flowchart
Doesn’t worry about syntaxSequence 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 LANGUAGEComputer 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 PROGRAMFree 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…)
1.2 STEPS INVOLVED IN THE PROGRAMMING PROCESS (CONT…)
SPESIFIKASI MASALAH
/KEPERLUAN
ANALISA & MEMBENTUK ALGORITMA
MENULIS ATURCARA(PENGATUCARAAN)
PENGATURCARAMENGUJI &
MENYAHRALAT(TESTING &
DEBUGGING)
LARIAN ATURCARAYANG TELAH
DIBANGUNKAN
1.2 STEPS INVOLVED IN THE PROGRAMMING PROCESS (CONT…)
TRUE
TRUE
FALSE
TWO TRUTH AND A LIE1. Understanding the programming problem
may 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.
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
Command Line Environment
GUI Environment
1.3 INTERACTIVE INPUT (CONT…)
1.3 INTERACTIVE INPUT (CONT…)
TRUE
TRUE
FALSE
TWO TRUTH AND A LIE1. A prompt is a message that is displayed
on a monitor, asking the user for a response.
2. The command prompt allows users to interact with a program in a graphical nontext environment.
3. The logic for a command line interactive program and a GUI interactive program basically the same.
o Eg: list thousands of people (personnel, student)
o Field – single data item (eg: name, address, salary)
o Records – groups of fileds (eg: Student record – NoMatrik, Grade)
o Files – groups of records (eg: Students in your class)
o Database - groups of files (tables)o Queries – related data items.
1.4 DATA HIERARCHY AND FILE INPUT
1.4 DATA HIERARCHY AND FILE INPUT (CONT…)
Bil Nama k/p Tel Bil Nama K/P Tel
Nama Alamat Asrama
Nama
K/P PNG PNGK
K/P Gaji
Nama Bil Anak Alamat Tel
BIODATA PELAJAR BIODATA PENSYARAH
PENGINAPAN PELAJAR
RESULT PELAJAR
GAJI PENSYARAH
MAKLUMAT KELUARGA
Field
RecordFile
1.4 DATA HIERARCHY AND FILE INPUT (CONT…)
TRUE
TRUE
FALSE
TWO TRUTH AND A LIE1. 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.
1. Nyatakan empat (4) operasi komputer2. Senaraikan enam (6) proses pengaturcaraan3. Berikan tiga (3) contoh bahasa pengaturcaraan4. Apakah tugas “Programmer”?5. Terangkan secara ringkas fasa ke-2 dalam proses
pengaturcaraan.6. Terangkan secara ringkas maksud ungkapan di bawah:
a) Promptb) Machine languagec) Command promptd) Logical errore) Syntaxf) Softwareg) Desk-checkingh) Compileri) coding
LATIHAN (1.1 – 1.4)
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 SYMBOLS AND PSEUDOCODE
STATEMENTS
Pseudocode Not final product Flexible
Example Start/stop begin/end Input myNumber get myNumber
read myNumber set myAnswer = myNumber * 2 calculate myAnswer = myNumber times 2 compute myAnswer as myNumber doubled myAnswer = myNumber * 2
Output myAnswer display myAnswer write myAnswer print myAnswer
1.5 FLOWCHART SYMBOL AND PSEUDOCODE STATEMENTS (CONT…)
DRAWING FLOWCHARTS
1.5 FLOWCHART SYMBOL AND PSEUDOCODE STATEMENTS (CONT…)
• Parallelogram - input symbol
• Rectangle - processing symbol
• Parallelogram - output symbol
• Arrow / Flowlines- Connect the steps
• Terminal symbols- Start / Stop
Flowchart and pseudocode of program that doubles a number
1.5 FLOWCHART SYMBOL AND PSEUDOCODE STATEMENTS (CONT…)
After developed flowchart or pseudocode1. Buy a computer2. Buy a language compiler3. Learn a programming language4. Code the program5. Attempt to compile it6. Fix the syntax error7. Compile it again8. Test with several sets of data9. Put into production
1.5 FLOWCHART SYMBOL AND PSEUDOCODE STATEMENTS (CONT…)
1.5 FLOWCHART SYMBOL AND PSEUDOCODE STATEMENTS (CONT…)
1.5 FLOWCHART SYMBOL AND PSEUDOCODE STATEMENTS (CONT…)
VARIABLES / IDENTIFIERName memory location. Eg:
RULES FOR NAMING VARIABLES.1. Must be one word (no space)2. Cannot used any symbol (eg: > + ) & $ @
# . ? )3. Some appropriate meaning4. Cannot start with number
1.6 NAME VARIABLES, ASSIGN VALUES TO
VARIABLES
myNumber calculatedAnswer2 44 85 10
Suggested Variable Names for Pelajar’s
Comments
namaPelajar GoodnamaPljr Goodnpljr Legal – but crypticnamaPelajarKolejShahputra Legal – but awkwardnama pelajar Not legal – embedded spaceNama_pelajar Legalnamapelajar Legal – but hard to read without
camel casingnama+Pelajar Not legal – symbol ‘+’Nama2_pljr Legal2_namaPljr Not legal – start with number_2namaPljr Legal
1.6 NAME VARIABLES, ASSIGN VALUES TO VARIABLES(CONT…)
ASSIGNMENT STATEMENTS Eg: calculatedAnswer = inputNumber*2
luasSegiempat = panjang * lebarkuasa_3 = nom * nom * nompurata = (Uj1+Uj2+Uj3)/3punca = b*b – (4*a*c)
Assignment operator Equal signLeft side – name the location where the
result will be stored Rules of precedence
Eg d = a + b * cd = (a + b) * c
1.6 NAME VARIABLES, ASSIGN VALUES TO VARIABLES(CONT…)
1.6 NAME VARIABLES, ASSIGN VALUES TO VARIABLES(CONT…)
TRUE
TRUE
FALSE1. The equal assignment operator always
requires the name of a memory location on its right side.
2. Variable names are easier to remember than memory addresses.
3. A variable name is also called an identifier.
TRUE4. Variable names must be one word, without spaces
5. As a programmer, you choose specific memory addresses for your variables. FALSE
Bina pseudocode utk soalan 1 dan 2, Bina cartalir utk soalan 3 dan 4.
1. Mengira luas segitiga2. Mencari kuasa 4 bagi nombor yang
dimasukkan3. Mengira isipadu sfera
isipadu = 4/3 j34. Mengira gaji
Gaji = (jam * 5.00) + bonus + elaun
LATIHAN
Infinite loopRepeating flow of logic with no end
Making decisionTesting a valueUse decision symbol (diamond shape)
Dummy value / Sentinel valuePreselected value that stops the execution of a program
eofend-of-file
1.7 SENTINEL, OR DUMMY VALUE TO END
PROGRAM
1.7 SENTINEL, OR DUMMY VALUE TO END PROGRAM (CONT…)
Start
get No
No = 0?
Ans = No * 2
print Ans
Stop
Start
get No
eof?
Ans = No * 2
print Ans
Stop
Program with sentinel value of 0 Flowchart using eof
1.7 SENTINEL, OR DUMMY VALUE TO END PROGRAM (CONT…)
TRUE
TRUE
FALSE
TWO TRUTH AND A LIE1. A program that contains an infinite loop is
one that never ends.
2. A preselected value that stops the execution of a program is often called a dummy value or a sentinel value.
3. Many programming languages use the term fe (for “file end”) to talk about a marker that automatically acts as a sentinel.
on-page connector symbol Circle
off-page connector symbol Square with pointed bottom
1.8 MANAGE LARGE FLOWCHART
Flowchart using the connector
1.8 MANAGE LARGE FLOWCHART(CONT…)
start
Step 1
Step 1
Step 1
1
1
Step 1
Step 1
Step 1
p.2 A
1.8 MANAGE LARGE FLOWCHART(CONT…)
TRUE
TRUE
FALSE
TWO TRUTH AND A LIE1. You can use a connector when limited
page size forces you to continue a flowchart in an unconnected location or on another page.
2. By convention, programmers use a parallelogram as an on-page connector symbol.
3. By convention, programmers use a symbol that look like a square with a pointed bottom as an off-page connector symbol.
DATA TYPES Text
String constant / text constantString variable / text variable
NumericNumeric constantNumeric variable
• Integer• Floating-point (fractional)
1.9 DATA TYPES, THE EVOLUTION OF
PROGRAMMING TECHNIQUE
Constant – value doesn’t
change
Variable– value can change
1.9 DATA TYPES, THE EVOLUTION OF PROGRAMMING TECHNIQUES (CONT…)
Bil Nama NoKP PNG Jantina Kolej Gred Byrn1 Farah 11122233
33.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, NoKP• Numeric Floating point – PNG, Byrn• Text string – Nama, Kolej• Text char – Jantina, Gred
Example:
Variable
• Numeric Integer - Markah = 90• Numeric Floating point – PIE = 3.142• Text string – Nama = “Siti”• Text char – Gred = “E”
Constant
Example: LuasS4 = Panjang * Lebar
Numeric Integer – LuasS4, Panjang, Lebar
LuasS3 = 0.5 * Tapak * TinggiNumeric Integer – Tapak, TinggiNumeric floating point – LuasS3
Gaji = (jam * 5.50) + elaun + BonusNumeric floating point – Gaji, elaun, Bonus, jam
If Markah >= 80Gred = ‘A’Numeric Integer – MarkahText 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
DDC1023 – focuses on procedural programming techniques.
1.9 DATA TYPES, THE EVOLUTION OF PROGRAMMING TECHNIQUES (CONT…)
1.9 DATA TYPES, THE EVOLUTION OF PROGRAMMING TECHNIQUES (CONT…)
TRUE
TRUE
FALSE
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.
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