Chapter 1
Introduction to Computer and Programming
1
Introduction
Think about some of the different ways that people use computers:
• In school, students use computers for tasks such as writing papers, searching for
articles, sending email, and participating in online classes.
• At work, people use computers to analyze data, make presentations, conduct business
transactions, communicate with customers and coworkers, control machines in
manufacturing facilities, and do many other things.
• At home, people use computers for tasks such as paying bills, shopping online,
communicating with friends and family, and playing computer games.
• And don’t forget that cell phones, iPods®, BlackBerries®, car navigation systems,
and many other devices are computers too.
• Thus, The uses of computers are almost limitless in our everyday lives.
2
Cont…
• Computers can do such a wide variety of things because they can be programmed.
• do any job that their programs tell them to do.
• program is a set of instructions that a computer follows to perform a task.
• Programs are commonly referred to as software.
• Software is essential to a computer because it controls everything the computer
does.
• All of the software that we use to make our computers useful is created by
individuals working as programmers or software developers.
• A programmer, or software developer, is a person with the training and skills
necessary to design, create, and test computer programs.
3
Hardware and Software
• Hardware
- The term hardware refers to all of the physical devices, or components, that a computer is
made of.
- A computer is not one single device, but a system of devices that all work together
- Typical computer system consists of the following major hard ware components:
• The central processing unit (CPU)
• Main memory
• Secondary storage devices
• Input devices
• Output devices
4
Typical components of a computer system
5
Hard ware components
• The CPU
• The central processing unit, or CPU, is the part of a computer that actually
runs programs.
• The CPU is the most important component in a computer because without it,
the computer could not run software.
• When a computer is performing the tasks that a program tells it to do, we say
that the computer is running or executing the program.
• Main Memory
• You can think of main memory as the computer’s work area.
• This is where the computer stores a program while the program is running, as
well as the data that the program is working with.
• CPU is able to quickly access data stored at any random location in RAM.
RAM is usually a volatile type of memory that is used only for temporary
storage while a program is running. When the computer is turned off, the
contents of RAM are erased. 6
Cont…
• Secondary Storage Devices
• Secondary storage is a type of memory that can hold data for long periods of
time, even when there is no power to the computer.
• Programs are normally stored in secondary memory and loaded into main
memory as needed.
• The most common type of secondary storage device is the disk drive.
• Most computers have a disk drive mounted inside their case.
• External disk drives, which connect to one of the computer’s communication
ports, are also available.
• External disk drives can be used to create backup copies of important data or
to move data to another computer.
7
Cont…
• Input Devices
• Input is any data the computer collects from people and from other devices.
• The component that collects the data and sends it to the computer is called an
input device.
• Common input devices are the keyboard, mouse, scanner, microphone, and
digital camera.
• Output Devices
• Output is any data the computer produces for people or for other devices.
• The component that display the data to the people
• Common output devices are video displays and printers.
8
Software
• Software
• If a computer is to function, software is not optional.
• Everything that a computer does, from the time you turn the power switch on until you shut
the system down, is under the control of software.
• Software is a set of instructions that tells the hardware what to do
• There are two general categories of software:
• System software and
• Application software
System Software
- The programs that control and manage the basic operations of a computer are
generally referred to as system software.
- System software typically includes the following types of programs:
Operating Systems:
- An operating system is the most fundamental set of programs on a
computer.
-The operating system controls the internal operations of the computer’s
9
hardware, manages all of the devices connected to the computer, allows data to be saved
Cont…
Utility Programs
- A utility program performs a specialized task that enhances the computer’s operation or
safeguards data.
- Examples of utility programs are virus scanners,file compression programs, and data backup
programs.
Software Development Tools
- Software development tools are the programs that programmers use to create, modify, and test
software.
- Example: Assemblers, compilers, and interpreters
Application Software
- These are the programs that people normally spend most of their time running on their computers.
Example: Microsoft office Application
10
How Computers Store Data
• All data that is stored in a computer is converted to sequences of 0s and 1s.
• A computer’s memory is divided into tiny storage locations known as bytes to
store a letter of the alphabet / number.
• Computer has to have lots of bytes,have millions, or even billions, of bytes of
memory.
• Each byte is divided into eight smaller storage locations known as bits
• Computer scientists usually think of bits as tiny switches that can be either
on or off.
11
When a piece of data is stored in a byte, the computer sets the eight bits to an on/off
pattern that represents the data.
12
Bit patterns for the number 77 and the letter A Respectively
13
How a Program Works
• A program is nothing more than a list of instructions that cause the CPU to
perform operations.
• A computer’s CPU can only understand instructions that are written in machine
language.
• The CPU does nothing on its own, It has to be told what to do using program
• A program can be stored on a secondary storage device such as a disk drive and has to
be copied into main memory, or RAM, each time the CPU executes it.
14
A program is copied into main memory and then executed
15
• When a CPU executes the instructions in a program, it is engaged in a process that
is known as the fetch-decode-execute cycle.
16
Introduction to computer program
Terms:
Computer:-
- is 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.
- The uses of computers are almost limitless in our everyday lives
Programming:-
- The process of instructing a computer to perform Tasks and solve problems
in real life.
17
Problem-Solving Using Computers
Problems:
• Undesirable situations that prevent the organization from fully achieving its
purpose, goals and objectives
• There could be many potential problems which are be categorized into
the following:
• The need to improve performance
• The need to improve information and data
• The need to improve economics (minimize cost and increase profit)
• The need to improve control/security
• The need to improve efficiency
• The need to improve service to customers, suppliers, partners, employees, etc
18
Cont.
• Problem solving is the process of transforming the description of a
problem into the solution of that problem by using our knowledge of
the problem domain and by relying on our ability to select and use
appropriate problem-solving strategies, techniques, and tools.
• In order to solve a given problem, computers must be given the correct
instruction about how they can solve it.
• The terms computer programs, software programs, or just
programs are the instructions that tells the computer what to do
• Computer programming (often shortened to programming or
coding) is the process of writing, testing, debugging/troubleshooting,
and maintaining the source code of computer programs.
19
Cont.
• A computer program usually consists of two elements:
• Data – characteristics
• Code – action
• Computer programs (also know as source code) is often written by
professionals known as Computer Programmers) using
programming Language
• A programming language is an artificial language that can be used to
control the behavior of a machine, particularly a computer
20
Computer Language
• Computer languages have relatively few, exactly defined rules for
composition of programs, and strictly controlled vocabularies in which
unknown words must be defined before they can be used.
• Programming languages can be divided in to two major categories:
low-level and high-level languages
21
Low-level languages
• In the initial years of computer programming, all the instructions were
given in binary form
• Computers only understand one language and that is binary language or
the language of 1s and 0s
• Although the computer easily understood these programs, it proved too
difficult for a normal human being to remember all the instructions in
the form of 0s and 1s
• machine language, one of low-level languages
• Assembly language correspondences symbolic instructions and
executable machine codes and was created to use letters to each
machine language instructions to make it easier to remember or write.
• Example, ADD A, B – adds two numbers in memory location A and B
22
High-level languages
• ignore many low-level details of the computer's hardware
• High-level languages are more English-like and, therefore, make it easier for
programmers to "think" in the programming language.
• High-level languages also require translation to machine language before
execution.
• translation is accomplished by either a compiler or an interpreter.
• Compilers translate the entire source code program before execution.
• Interpreters translate source code programs one line at a time.
Examples:FORTRAN (FORmula TRANslator), BASIC (Bingers All Purpose
Symbolic Instruction Code), PASCAL, C, C++, Java are some examples of high-
level languages.
23
Programming Paradigm
• A programming paradigm provides the programmer's view of code
execution.
Procedural Programming Languages
- specifies a list of operations that the program must complete to reach
the desired state.
- Each program has a starting state, a list of operations to complete, and
an ending point.
- Integral to the idea of procedural programming is the concept of a
procedure call.
24
Cont.
Structured Programming Languages
• Structured programming requires that programmers break program
structure into small pieces of code that are easily understood
• It is often associated with a "top-down" approach to design.
• The top-down approach begins with an initial overview of the system
that contains minimal details about the different parts. Subsequent
design iterations then add increasing detail to the components until the
design is complete
25
Cont.
Object-Oriented Programming Languages
• Object-oriented programming is one the newest and most powerful
paradigms.
• In object- oriented programs, the designer specifies both the data
structures and the types of operations that can be applied to those data
structures.
26
Problem-Solving Approaches
Top-down development
• a systematic approach based on the concept that the structure of the
problem should determine the structure of the solution.
• The systems is viewed as an entity and broken down into key
components.
Bottom-Up Development
• Bottom-up is the reverse process where the lowest level components
are built first and the system builds up from the bottom until the whole
process is finally completed.
27
Systems Development Life Cycle (SDLC)
• SDLC is a conceptual model used in project management that describes the
stages involved in a computer system development project from an initial
stage of preliminary investigation through maintenance of the completed
application.
• The software life cycle has the following components
• Preliminary Investigation
• Analysis
• Design
• Implementation
• Testing
• Maintenance
28
Preliminary Investigation
• Defining the problem (examine documents, work papers, and
procedures; observe system operations; interview key users of the
system).
• Suggesting a solution (often improving an existing one or building a new
information system)
• Feasibility study (determine whether the solution is feasible)
• Technical feasibility: whether implementation is possible with the
available or affordable hardware, software and other technical
resources.
• Economic feasibility: whether the benefits of the proposed solution
outweigh the costs
• Operational feasibility: whether the proposed solution is desirable
within the existing managerial and organizational framework 29
Analysis
• Requirement specification
• Define the specific information requirements: who needs what
information, where, when, and how.
• Present a detail description of the functions the new system
must perform
30
Design
• Based on the requirements specified in the analysis phase algorithms
are developed at this stage.
• Develop a series of steps with a logical order which, when applied to
the input would produce the specified output.
• Consider alternative technology configurations to develop the
system (hardware, software, security capability of the system,
network alternatives etc.)
• Management and control of the technical realization of the system:
detailed program specification,
31
Implementation
• During implementation, we translate (code) each step of the algorithm
in the design specifications into a statement in the particular language
selected, and end up with a computer program.
32
Testing (Will the system produce the desired results?)
• Unit testing (Program testing): test each unit of program in the
system separately
• System testing: test the functions of the system as a whole
(performance, capacity for file storage, recovery and restart
capabilities)
• Acceptance testing: system is evaluated by users and management
33
Maintenance
• Changes in hardware, software, documentation, or procedures to
correct errors, meet new requirements, or improve processing
efficiency.
• Fix bugs found by the customer
• Make modifications
• Add new features
34
Problem solving Techniques with Algorithm Development
• An algorithm is defined as a step-by-step sequence of instructions that must
terminate and describe how the data is to be processed to produce the desired
outputs.
• Simply, algorithm is a sequence of instructions.
• Algorithms are a fundamental part of computing.
• An algorithm needs to be
• Precise and unambiguous (no ambiguity in any instruction and in the order of execution)
• Simple
• General (one inch is equal to 2.54cm is not an algorithm, it has to convert a supplied number of
inches)
• Correct
• Finite (has to have an end)
• Handles all exceptions
• Produce expected output
• Efficient: in time, memory and other resources 35
Cont.
• The three commonly used tools to help to document program logic (algorithm)
Pseudocode:
-is a compact and informal high-level description of a computer algorithm that
uses the structural conventions of programming languages, but typically omits
details such as subroutines, variables declarations and system-specific syntax.
- it may be easier for humans to read than conventional programming languages,
36
Cont.
• Example:
Pseudo-code: similar to real code,
IF Mark>80
Grade<--A
ELSE IF Mark>=70
Grade<--B
ELSE IF Mark>=60
Grade<--C
ELSE IF Mark>=50
Grade<--D
ELSE
Grade<--F
ENDIF
37
Structured Charts
• Depicts the logical functions to the solution of the problem using a
chart
• It provides an overview that confirms the solution to the problem
without excessive consideration to detail
38
Flowchart
• Flowchart is a diagram consisting of labeled symbols, together with
arrows connecting one symbols to another.
• Flowchart uses different symbols (geometrical shapes) to represent
different processes.
39
Flowchart Symbols:
40
• Example 1: - Draw flow chart of an algorithm to add two numbers and
display their result.
• Algorithm description
• Read the rules of the two numbers (A and B)
• Add A and B
• Assign the sum of A and B to C
• Display the result ( c)
41
• Example 2: Write an algorithm description and draw a flow chart to check a
number is negative or not.
• Algorithm description.
• 1/ Read a number x
• 2/ If x is less than zero write a message negative
• else write a message not negative
42
• Example 3: - Write the algorithmic description and draw a flow chart
to find the following sum. Sum = 1+2+3+…. + 50
• Algorithmic description
• 1. Initialize sum to 0 and counter to 1
1.1. If the counter is less than or equal to 50
• Add counter to sum
• Increase counter by 1
• Repeat step 1.1
1.2. Else
• Exit
• 2. Write sum
43
Thank You !!!
End of Chapter one
44