2. Introduction to computers
and programming
What is a Computer?
How do computer works?
Computer System Parts
Quiz
Computer Language
What is Programming?
Problem Solving Steps:
Algorithm
Pseudocode
Flow Charts
• Lab Problem
• Write Pseudocode
• Draw Flow Chart
• Home Work
• Write Pseudocode
• Draw Flow Chart
3. What is Computer?
• A programmable electronic machine that
performs
• high-speed mathematical or logical
operations
• that assembles, stores, processes
information.
• A computer is a machine that receives
input data which it then
processes/compute and outputs the
results.
6. Parts of a Computer System:
• Two Parts
• Hardware
• Software
• Hardware: Physical Electronic Devices
• Input : Keyboard, Mouse
• System unit:
• Random Access Memory (RAM)
• Central Processing Unit (CPU)
• Output: Monitor, Printer
• Secondary Storage: Disk Drive
7. Parts of a Computer System: Hardware
Mouse
Camera
Scanner
Keyboard
Price
Scanner
Speakers
Printer
Monitor
8. Parts of a Computer System: Software
Instructions for the hardware.
Actions to be performed
A set of instructions is called a program.
Driving force behind the computer
Without a program – What is a computer?
Collection of Useless Hardware
2 purposes:
Tell the computer what to do
Tell other people what we want the computer to do.
9. QUIZ
What are the four basic components of a computer?
A. Input devices, output devices, printing, and typing
B. Input devices, processing unit, storage, and output devices
C. Input devices, cpu, output devices, and RAM
What does a storage unit provide?
A. A place to show data
B. A place to store currently worked on information
C. A place to store information
10. QUIZ
What are examples of storage devices?
A. Keyboards, flash drive, printer
B. Flash drive, RAM, DVD-ROM
C. Hard drive, DVD-ROM, flash drive
What is the processing unit?
A. The brains of the computer
B. This the main circuit board that all other internal components are
connected to.
C. A device that receives, processes, and presents information.
11. What Language Computer Understand?
• Uses Binary Language - which is “0”
and “1”
• A single digit (0 or 1) is called a bit
• A byte is made up of 8 bits.
• Data and instructions (numbers,
characters, strings, etc.) are encoded
as binary numbers - a series of bits
(one or more bytes made up of zeros
and ones)
12. What is Programing?
• Computer programs are a detailed set of instructions given to the
computer
• They tell the computer:
1. What actions you want the computer to perform
2. The order those actions should happen in
• Examples:
1. Adding two numbers
2. Drawing Circle
• An effective program therefore needs:
1. A thorough understanding of the problem
2. A well thought-out, step-by-step solution to the problem
3. The most valuable part of learning to program is learning how to think about
arranging the sequence of instructions to solve the problem or carry out the
task
13. Problem Solving?
• A Good Problem Solver is Better Programmer
• Problem Solving Steps -
1. U – Understand the Problem
2. D – Devise a Good Plan to Solve
3. I – Implement the Plan
4. E – Evaluate the Solution
14. Step 1 - Understand the Problem
• What
is the Problem to be solved?
is the unknown?
is the condition?
is the data?
is needed to solve the problem?
actions need to take place?
• Identify the inputs and outputs
• Identify the processes needed to produce the outputs from the
given inputs
• Draw a figure. Introduce suitable notation.
• Isolate Principle parts of the problem.
15. Step 2 - Devise a Plan
Find connections between the knowns and unknowns.
Simplify: Break the problem into smaller sub-problems
Design a solution
Make a plan or list of actions to implement the solution
Algorithm / Flowchart / Psuedocode
16. Step 2 - Devise a Plan (cont.)
• Algorithm
• A FINITE set of clear, executable steps that will eventually
terminate to produce the desired outcome
• Logical design used to solve problems – usually a list of
actions required to perform task
• Pseudocode
• Written like program code but more “English Like” and
doesn’t have to conform to language syntax
• Flowchart
• Diagram that visually represents the steps to be performed
to arrive at solution.
17. Step 3 - Implement the Plan
Implement in a Programming Language
Carry out the plan checking the preliminary results at each
step.
Code A Little - Test A lot
18. Step 4 - Evaluate the Solution
• Run the Code
• Check results repeatedly and thoroughly
• Use numerous test cases or data sets
• Use highly varied test case, including expected as well as
and unexpected cases
• Look for new solutions
• Is there a better, easier, or more efficient solution
• Can other problems be solved using these techniques?
19. FLOW CHART SYMBOLS
TERMINAL – the beginning or ending of
a program
INPUT/OUTPUT – where the user of the program
is asked for information (INPUT) or where the
program displays a result (OUTPUT)
PROCESSING – shows any mathematical
operation
CALL – shows any other pieces of the
program that are called upon
DECISION – represents any action where the
computer is making a decision
20. Problem 1:
Write an algorithm and draw a flowchart that will read the two
sides of a rectangle and calculate its area.
Pseudocode:
• Input the width (W) and Length (L) of a rectangle
• Calculate the area (A) by multiplying L with W
• Print A?
21. Problem 1:
Algorithm:
Step 1: Input W, L
Step 2: A L x W
Step 3: Print A
FlowChart
Start
Input W and L
A = L x W
Print A
Stop
22. Problem 2:
Write an algorithm to determine a student’s final grade and indicate
whether it is passing or failing. The final grade is calculated as the
average of four marks (50).
Pseudocode:
• Input a set of 4 marks
• Calculate their average by summing and dividing by 4
• if average is below 50
• Print “FAIL”
• else
• Print “PASS”
23. Problem 2:
Detailed Algorithm:
Step 1: Input M1,M2,M3,M4
Step 2: GRADE (M1+M2+M3+M4)/4
Step 3: if (GRADE < 50) then
Print “FAIL”
else
Print “PASS”
Endif
24. Programming Fundamentals: Putting
the Instructions Together
• Sequential Processing
• A List of Instructions
• Conditional Execution
• Ifs
• Repetition
• Looping / Repeating
• Stepwise Refinement / Top-Down Design
• Breaking Things into Smaller Pieces
• Calling Methods / Functions / Procedures / Subroutines
• Calling a segment of code located elsewhere
• Reuse of previously coded code segment
25. Methods of Programming
• Procedural
• Defining set of steps to transform inputs into outputs
• Translating steps into code
• Constructed as a set of procedures
• Each procedure is a set of instructions
• Object-Oriented
• Defining/utilizing objects to represent real-world entities that work
together to solve problem
• Basic O-O Programming Components
• Class
• Object/Instance
• Properties
• Methods
26. Home Work
Write an algorithm, pseudo code and flow chart to read three
numbers and print the largest number.