(M2-MAIN) Introduction To Computer and Programming Concepts
(M2-MAIN) Introduction To Computer and Programming Concepts
CPE0003L
MODULE 2.1
INTRODUCTION TO
COMPUTER Concept
At the end of the lesson, the student should be able to:
• Define what is computer programming
• Define terms related to computer programming such as source code, programs, etc.
• Know the difference between an Assembly Language and Machine Language
• Describe what are the low and high-level languages
• Know the difference between procedural and object-oriented programming
Computer Program
A computer program (also a software program, or just
a program) is a sequence of instructions written to perform a
specified task for a computer. A computer requires programs
to function, typically executing the program's instructions in
a central processor. The program has an executable form
that the computer can use directly to execute the instructions.
Source Code
Source code is text written in a
computer programming language. Such a language is
specially designed to facilitate the work of
computer programmers, who specify the actions to be
performed by a computer mostly by writing source
code, which can then be automatically translated to
binary machine code that the computer can directly
read and execute.
Computer Programming
Computer programming (often shortened to programming
or coding) is the process of designing, writing, testing,
debugging/ troubleshooting, and maintaining the source
code of computer programs. This source code is written in a
programming language. The purpose of programming is to
create a program that exhibits a certain desired behavior.
The process of writing source code often requires expertise
in many different subjects, including knowledge of the
application domain, specialized algorithms and formal logic.
Introduction to Programming
• Program: self-contained set of
instructions used to operate a
computer to produce a specific
result
• Also called software
• Programming: the process of
writing a program, or software
6
Machine Language
• Machine language programs, also
called executables, consist of binary
instructions
• Each instruction has two parts:
• Instruction part: the operation to be
performed; also called an opcode
• Address part: memory address of
the data to be used
• Each class of computer has its own
particular machine language
• Writing in machine language is tedious!
7
Assembly Languages
• Assembly Language: programming
language with symbolic names for
opcodes, and decimals or labels for
memory addresses
Example:
ADD 1, 2
MUL 2, 3
• Assembly language programs must be
translated into machine instructions,
using an assembler
8
Introduction to Programming: Assembly Language
(continued)
9
Introduction to Programming:
• Low-level languages: languages
that use instructions tied directly to
one type of computer
Examples: machine language,
assembly language
10
Introduction to Programming: (continued)
11
Low- and High-Level Languages (continued)
12
Low- and High-Level Languages (continued)
13
Procedural and Object Orientations
Figure 1.2
Creating an
executable C++
program.
14
MODULE 2.2
ALGORITHM, PSEUDOCODE
AND FLOWCHARTS
At the end of the lesson, the student should be able to:
• Discuss Algorithms, Pseudocode and Flowcharting.
• Create Algorithm and Pseudocode.
• Draw Flowcharts
Algorithms
16
Algorithms (continued)
• Pseudocode: English-like phrases used to
describe the algorithm
• Formula: description of a mathematical
equation
• Flowchart: diagram showing the flow of
instructions in an algorithm
– Flowcharts use special symbols
17
Expressing Algorithms
Algorithms can be expressed in many kinds of notation,
including:
• Natural Languages
• Pseudocode
• Flowcharts
• Programming Languages
Pseudocode
• A program design technique that uses English words.
• Has no formal syntactical rules.
• Pseudo means false, thus pseudocode means false code. It
looks like (imitates) real code but it is NOT real code.
• Pseudocode cannot be compiled nor executed, and there are
no real formatting or syntax rules.
• Pseudocode should not include keywords in any specific
computer languages.
• The benefit of pseudocode is that it enables the programmer to
concentrate on the algorithms without worrying about all the
syntactic details of a particular programming language.
How do I write Pseudocode?
✓ First you may want to make a list of the main tasks that must be
accomplished on a piece of scratch paper.
Pseudocode:
Pseudocode:
Write a program that will allow the student to input the grade
on his 5 subjects and will compute for his average grade.
If age > 17
Display a message indicating you can vote.
Else
Display a message indicating you can't vote.
Endif
Case of age
0 to 17 Display "You can't vote."
18 to 64 Display "Your in your working years."
65 + Display "You should be retired."
Endcase
Pseudocode example : While loop
Function main
Pass In: nothing
Doing some lines of code
Call: clear monitor
Doing some lines of code
Pass Out: value zero to the operating system
Endfunction
Flowcharts Symbols
Flowcharts Symbols (continued)
Flowcharts (continued)
33
Guidelines for Drawing a Flowchart
• Only one flow line should enter a decision symbol, but two or
three flow lines, one for each possible answer, should leave the
decision symbol.
• If the flowchart becomes complex, it is better to use
connector symbols to reduce the number of flow lines.
Avoid the intersection of flow lines if you want to make it
more effective and better way of communication.
Example 1
1. Start
2. Read quantity
3. Read price_per_kg
4. price quantity *
price_per_kg
5. Print price
6. End
Flowchart: Calculate Price of Apples
Start
Input
Quantity
Input
Price_per_kg
Output
Price
End
Example #2
• Entry_time Charge
????
• Exit_time
Flowchart: Calculate Car Park Charge
Start
Input Entry_time
Input Exit_time
Output
Charge
End
ASK ANY QUESTION RELATED TO OUR TOPIC FOR TODAY.