Introduction to
Computer
Programming
Computer a way of giving computers
Programming instructions about what they
should do next.
These instructions are
known as code, and
computer programmers
write code to solve problems
or perform a task.
2
Computer Programming is the creation
Programming of an ordered set of
instructions to solve a
problem with a computer.
The instructions sometimes
referred to as codes make up
a computer program.
3
Program is a collection of instructions
that performs a specific task
when executed by a computer
designed by a computer
programmer.
4
Programming Programming needs a
Language language called Programming
Language to communicate with
computers.
5
Steps in
Programming
Process
Programming Steps
1.Problem 2. Algorithm 3. Desktop
definition design Testing
6.
5. Testing and
Documentation 4. Coding
debugging
(Optional)
1. Problem definition
• What information (inputs), is given to you to use
to solve the problem?
• What will the solution (outputs) of the problem,
look like?
• What calculations (processes), will be used to
change the input information into the desired
output?
2. Algorithm Design
• Break the problem into the steps of what must
be done to solve the problem.
• List what tasks need to be done to solve the
problem.
• Expand the outline into a complete solution. It
should list all the steps that need to be done, in
the correct order they need to be done in.
3. Desktop Testing
• In this step, you pretend to be a computer and
execute the steps in the algorithm.
• Don't add steps, or leave out any steps. Don't
rearrange the steps.
• If you don't get the right answer to the problem,
then you have an error in the algorithm. Fix it and
try again until you get the right answer.
4. Coding
• Once the algorithm, or complete outline works
correctly, you need to translate the algorithm
into a computer language that your computer
understands.
5. Testing and Debugging
• Now, enter the program into the computer, enter
some test data, and have the computer execute
the program.
• If you get the correct answer to the problem, the
program works!
• Otherwise, look for errors in the program and try
again.
6. Documentation (Optional)
• You may want to write a user’s manual in order
for users of your program will know how to use it
properly and step by step.
• Once the program works correctly, you want
make sure the documentation is up to date and
be ready to maintain the program.
Program Logic
Formulation
Logical The use of logical thinking in
Reasoning order to find results or draw
conclusions.
15
Algorithm An algorithm is a logical
sequence of steps for solving a
problem that can be translated
into a computer program.
16
Algorithm Pseudocode
Flowchart
17
Pseudocode A pseudocode is an artificial
and informal language that
helps programmers develop
algorithms. It is usually a
combination of English words
and some keywords of a
programming language.
18
Pseudocode
19
Pseudocode
20
Flowchart A flowchart is a diagram that
represents the sequence of
operations in a process. It is a
graphic representation of an
algorithm.
21
Flowcharting Symbols
Terminal. Marks the starting or
Oval ending point of the flowchart
Process. Represents a single step,
Rectangle or an entire sub-process within a
larger process
Input/Output. Represents material
Parallelogram or information entering or leaving the
system
Connector. Indicates that the flow
Circle continues where a matching symbol
has been placed
Flow Lines. Lines indicate the
Arrows sequence of steps and the direction
of flow
22
Flowcharting Symbols
Off-Page Connector. Indicates that
the process continues off page.
Pentagon
Decision. A branching point; lines
representing different decisions
Diamond emerge from different points of the
diamond
I ni ti al i zati on. Used t o p r e p a r e
components of a program
Hexagon
23
Notations commonly used in Flowcharting
NOTATION MEANING
+ Addition
- Subtraction
* Multiplication
/ Division
** Exponentiation
() Grouping
= Equal to
> Greater than
< Less than
<> Not Equal to
>= Greater than or Equal to
<= Less than or Equal to
Y Yes
N No
24
Rules of Drawing Flowcharts
for Algorithms
1. All boxes of flowcharts are connected with
arrows to show the logical connection between
them,
2. Flowcharts will flow from top to bottom,
3. All flowcharts start with a Start Box and end
with a Terminal Box,
Flowchart
Examples
Example # 1: Algorithm:
Calculate the Step 1: Read amount,
Step 2: Read years,
Interest of a Bank Step 3: Read rate,
Deposit Step 4: Calculate the
interest with formula
"Interest=Amount*Years*Rate
/100
Step 5: Print interest,
27
Example # 1:
Calculate the
Interest of a Bank
Deposit
28
Example #2: Algorithm:
Determine and Step 1: Read number N,
Step 2: Set remainder as N
Output Whether modulo 2,
Number N is Even or Step 3: If remainder is
Odd equal to 0 then number N is
even, else number N is odd,
Step 4: Print output.
29
Example #2:
Determine and
Output Whether
Number N is Even or
Odd
30
Example #3: Algorithm:
Determine Whether Step 1: Input temperature,
Step 2: If it is less than 32,
a Temperature is then print "below freezing
Below or Above the point", otherwise print "above
Freezing Point freezing point"
31
Example #3:
Determine Whether
a Temperature is
Below or Above the
Freezing Point
32
Example #4: Algorithm:
Determine Whether Step 1: Input grades of 4
courses M1, M2, M3 and M4,
A Student Passed Step 2: Calculate the average
the Exam or Not grade with formula
"Grade=(M1+M2+M3+M4)/4"
Step 3: If the average grade is
less than 60, print "FAIL", else
print "PASS".
33
Example #4:
Determine Whether
A Student Passed
the Exam or Not
34
Thank You!