Chapter 1 - Introduction
Chapter 1 - Introduction
Chapter 1 Introduction
Compiled by: Kidane W.
1
Introduction
• Computer
• an electronic device that accepts data, performs computations, and makes logical
decisions according to instructions that have been given to it
• then produces meaningful information in a form that is useful to the user
• Computer programs
• Sets of instructions that control a computer’s processing of data
• Computer programming
• is the process of writing,, debugging / troubleshooting, testing and maintaining the source code of computer
programs.
2
3
Introduction
• Central Processing Unit (CPU) - The part of the computer that executes the instructions
(program) stored in memory. The CPU is made up of the Control Unit and the
Arithmetic/Logical Unit.
• Control Unit - The component of the CPU that controls the actions of the other components
so that instructions are executed in the correct sequence.
• Arithmetic/Logical Unit (ALU) - the component of the CPU that performs arithmetic and
logical operations.
• Memory Unit - Internal data storage in a computer. The memory is comprised of a large
number of individual cells, each with a unique number, known as its address, associated
with it.
4
Introduction
• Computer programs (also know as source code) is often written by
professionals known as Computer Programmers
5
What is a program ?
A program is a sequence of instructions that specifies how to
perform a computation and written in a language the computer
understands.
The computation might be something mathematical, such as
solving a system of equations or finding the roots of a polynomial.
But it can also be a symbolic computation, such as searching and
replacing text in a document or (strangely enough) compiling a
program.
What’s a Program?
7
Program Components
• A few basic instructions appear in every language:
1. Input - Get data from the keyboard, a file, or some other device.
2. Output - Display data on the screen or send data to a file or other
device.
3. Math Perform basic mathematical operations like addition and
multiplication.
4. Conditional execution - Check for certain conditions and execute the
appropriate sequence of statements.
5. Repetition/Looping - Perform some action repeatedly, usually with
some variation.
Programming: a way of thinking
Combines features from mathematics, engineering, and
natural science.
Like mathematicians, computer scientists use formal languages to
denote ideas (specifically computations).
Like engineers, they design things, assembling components into
systems and evaluating tradeoffs among alternatives.
Like scientists, they observe the behavior of complex systems, form
hypotheses, and test predictions.
Programming: a way of thinking
11
A Programming Language
• an artificial language that can be used to control the behavior of a computer
which is defined by:
• Syntactic - describes the possible combinations of symbols that form a syntactically correct
program
12
A programming Language
• Machine language
• the binary representation of the instructions that a computer's
hardware can perform
• different computers understand different sequences
• hard for humans to understand: 01010001…
• Assembly language
• a low-level programming language in which a mnemonic is
used to represent each of the machine language instructions
for a specific computer.
• Still hard for humans to understand:
13
Source Program - A program written in a human readable version.
Object Program - The machine language version of a source
program.
14
Programming Language
• High-Level Language - A computer language that is more understandable and
closer to standard notations than assembler language.
• For example , C++ is a high-level language based on algebraic notation.
Interpreting vs. Compiling Programs
• Each type of computer only “understands” its own machine language (zeroes
and ones)
• Compiler: human translator translates book in its entirety and then translated
book is printed and read
17
Programming paradigm
• A computer program usually consists of two elements:
• Data – characteristics
• Code – action
• Some program development approaches conceptually organize the program around the code:
• known as Process oriented approach/ method, which characterizes the program as serious linear steps.
• Ask not what your code does to your data structure, but what your data structure can do for you 19
Programming paradigm…
• A programming paradigm is a fundamental style of programming
• Unstructured Programming
• Procedural programming
20
Unstructured Programming
• Consisting only of one large (usually main) program
• disadvantages
• Complex
• if the same statement sequence is needed at different locations within the
program, the sequence must be copied
21
Procedural programming
22
Procedural programming
• We have a single program, which is divided into small pieces called procedures
• Advantage
• to re-use the same code at different places in the program without copying it
• easier way to keep track of program flow
• Example
• FORTRAN, ADA
23
Object Oriented Programming - OOP
• Is a method of implementation in which programs are organized as
cooperative collections of objects
• Data and operations are grouped together
24
Problem Solving
• The ability to solve problems is a basic life skill and is essential to our day-to-day
lives, at home, at school, and at work. We solve problems every day without really
thinking about how we solve them.
• For example: it’s raining and you need to go to Bate. What do you do? There are
lots of possible solutions.
1. Take your umbrella and walk.
2. If you don't want to get wet, you can drive, or take the bus.
3. You might decide to call a friend for a ride, or you might decide to go to Bate another day.
There is no right way to solve this problem and different people will solve it differently.
25
Problem solving Techniques
• Computer solves varieties of problems that can be expressed in a finite number of
steps
• A program
• solve a problem : should be effective
27
Algorithm
• Writing a logical step-by-step method to solve the problem is called
the algorithm. In other words, an algorithm is a procedure for solving
problems. In order to solve a mathematical or computer problem,
this is the first step in the process.
28
Programs vs. Algorithms
• To make a computer do anything, you have to write a program
• To write a computer program, you have to tell the computer, step by step, exactly what
you want it to do.
• The computer then "executes" the program, following each step mechanically, to
accomplish the end goal.
29
Pseudocode
• is an artificial and informal language that helps programmers
develop algorithms
• allows the designer to focus on the logic of the algorithm without
being distracted by details of programming language syntax
• “text-based" detail (algorithmic) design tool
• Pseudocode is not a rigorous notation, since it is read by other
people, not by the computer.
30
Pseudocode
• Computation/Assignment • Conditional
if "condition"
"variable" equals "expression" or (subordinate) statement 1
"variable" = "expression" else
(subordinate) statement 2
• Input/Output
• Iterative
get "variable", "variable", ... while "condition"
display "variable", "variable", ... (subordinate) statement 1
31
Pseudocode
• Write a program that prints “passed” when the student grade is greater than 60 and
“failed” otherwise.
If student's grade is greater than or equal to 60
Print "passed"
else
Print "failed“
• Pseudo-code for computing the final price of an item after the sales tax rate. Note the
three types of instructions: input (get), process/calculate (=) and output (display)
1. get price of item
2. get sales tax rate
3. sales tax = price of item times sales tax rate
4. final price = price of item plus sales tax
5. display final price
6. stop
• Variables: price of item, sales tax rate, sales tax, final price
32
Flowchart symbols
A graphic representation of an algorithm, often used in the design phase of
programming to work out the logical flow of a program.
• Action\operation Symbol
• Instructions changing a state
• Decision Symbol
• Instructions testing a state
• Flowline
• Instructions transferring to next step
• Start/End Symbol
• Input/output symbol
33
Decision Structure
34
Repetition(Looping) Structure
• Notice the use of the diamond symbol. A loop tests a condition, and
if the condition exists, it performs an action. Then it tests the
condition again. If the condition still exists, the action is repeated.
This continues until the condition no longer exists.
35
GUIDELINES DRAW A FLOWCHARTS
1. The A flowchart should be clear, neat and easy to follow.
2. The usual direction of the flow of a procedure or system(arrow) is
from “Left to Right” or “ Top to Bottom”.
3. Only one flow line should come out from a process symbol.
4. Only one flow line should enter a decision symbol.
5. Ensure that the flowchart has a logical start and finish.
36
Flowchart Examples
• Single Selection (if)
• If you’ve won the lottery:
raise your hand True
Won Raise
lottery? Hand
False
37
Selection (continued)
• Multiple Selection (switch)
• If the light is ... Light True
Stop
Red?
• red -> stop
False
• green -> go True
• yellow -> slow down Light
Green? Go
False True
Light Slow
Yellow? Down
False
38
Teaching a baby to count from 1 to
10: Repetition
counter = 1
if counter <= 10: Counter = 1
increment counter
Add 1
print counter number to counter
Counter True
Print
≤ 10? counter
False
39
Exercises:
Draw a flow chart for the following series
• Sum=2+4+6+....+n
• Sum=1+3+5+7+...+n
• Sum=12 + 22+...+n2
• Sum=1-2+3-4+5-6+7....n
40
System Development Life Cycle
(SDLC)
1. Feasibility Study
2. Requirements analysis
3. Designing solution
4. Testing designed solution
5. Implementation
6. Unit testing
7. Integration and System testing
8. Maintenance
41
Development of Computer Solution
1. Identify or Define the problem
2. Analyze the problem in terms of inputs,
outputs, formulas, constants)
3. Design the Solution
4. Implement (program coding)
5. Evaluate
Analyze the problem
We need to read it till we understand every detail
We need to dissect the problem into its component parts (e.g.
problems and sub-problems)
We need to remove any ambiguity, extra information
We need to determine our known and our unknowns
We need to be aware of any assumptions we are making.
Design the solution
• Define things once and only once and let computers repeat and execute tasks:
[Rule of 3]
• Only implement functionality that is required, rather than trying to anticipate future
needs.
• The single responsibility principle (SRP): Each module should have a single, well-
defined responsibility.
• Open-closed principle (OCP): Code should be open for extension but closed for
modification.
47
Principles of Computer Programming
• Write programs for people, not computers: Make your code easy to understand
for humans. If your code looks very complex or messy, you’re probably doing it
wrong.
• Optimize software only after it works correctly: Even experts find it hard to predict
performance bottlenecks.
48
End of Chapter One
49
Bloom’s Taxonomy (1st Year –2nd Year)
50
Unified domain taxonomy (3rd & 4th Year)
There have been a number of attempts to produce a taxonomy that covers the cognitive (C), affective (A) and psychomotor (P)
domains. The work of De Block.
Level C-A-P
Knowledge C: Repeat, define, show, name, etc.
A: Listen to opinion of others, accept notes, realize, etc.
P: Show, imitate, understand sound, smell, taste, etc.
Understanding C: Describe, characterize, say in own words, explain, compare, etc.
A: Accept opinions of others, answer questions, react to rules correctly, ask relevant
questions, participate, etc.
P: Demonstrate a principle, put together and disassemble something that is known, etc
Application C: Solve, calculate, number, translate, illustrate, analyze, make, etc.
A: React to rules automatically, accept norms and values, cooperate in a group, apply
norms and rules, etc.
P: Make, produce, try, repair, adapt, cook, cut, put together and disassemble
something that is new, etc.
Integration C: Design, create, summarize, judge, decide, plan, etc.
A: React to rules spontaneously, apply norms spontaneously and behave under rules,
initiate cooperation, find satisfaction in behavior and work under society’s rules, etc.
P: Perform an activity fluently, without hesitation, without mistakes, automatically; work
precisely, quickly, etc.
51
Two Dimensional Adaptation of Bloom’s
Taxonomy – The Matrix Taxonomy
• The dimensions of the matrix
represent the two separate
ranges of competencies:
1. the ability to understand and
interpret an existing product (i.e.
program code), and
2. the ability to design and build a
new product.
• The idea of a cognitive learning
taxonomy can also be used in an
iterative, spiral way.
• Create could be described as the
ability to combine one subject with
others in order to build new solutions.
52
Programming Activities
• Model: illustrate or create an abstraction
• Adapt: modify a solution for other domains/ranges
of a solution
• Analyze: probe the [time] complexity of a solution
• Present: explain a solution to others
• Apply: use a solution as a component in a larger
• Recognize: base knowledge, vocabulary
problem
of the domain
• Debug: both detect and correct flaws in a design
• Refactor: redesign a solution (as for
• Design: devise a solution structure optimization)
• Implement: put into lowest level, as in coding a • Relate: understand a solution in context
solution, given a completed design. of others