An Introduction to Programming

Download Report

Transcript An Introduction to Programming

Introduction
An Overview of a
Microcomputer System and
Programming
Md. Manzoor Murshed
Associate Professor
Upper Iowa University
7/17/2015
Md. Manzoor Murshed
1
Lesson A
An Introduction to
Hardware and Software
7/17/2015
Md. Manzoor Murshed
2
1
Lesson A Objectives
 Describe
the components of a
microcomputer system
 Explain the relationship between
hardware and software
 Understand the history of
programming languages
 Understand the terminology used in
object-oriented languages
7/17/2015
Md. Manzoor Murshed
3
Introduction to
Microcomputer Systems
1
 First
appeared in marketplace in
1977
 Also called personal computers
 Composed of hardware and software
– Hardware
 Physical
components of the system
– Software
 Programs
(step-by-step instructions) that
tell the hardware how to perform a task
7/17/2015
Md. Manzoor Murshed
4
1
7/17/2015
Introduction to
Microcomputer Systems
Md. Manzoor Murshed
5
1 The Relationship between
Hardware and Software

Hardware
– System unit
 Internal
memory (RAM and ROM)
 Central processing unit (CPU)
– Input devices
– Output devices
– Peripheral devices

Software
– Operating system software
– Application software
7/17/2015
Md. Manzoor Murshed
6
1
7/17/2015
The System Unit
Md. Manzoor Murshed
7
1
System Unit: Internal Memory
7/17/2015
Md. Manzoor Murshed
8
System Unit:
RAM versus ROM
1
 Random-Access
Memory (RAM) chips
– User can read and write to memory
– Volatile
 Read-Only
Memory (ROM) chips
– User can only read from memory
– Nonvolatile
7/17/2015
Md. Manzoor Murshed
9
1
System Unit: CPU
The brain of the computer
 Resides on a microprocessor chip
 Contains two components

– Control unit
 Makes
sure the computer correctly processes
program instructions and data stored in internal
memory
– Arithmetic/Logic Unit (ALU)
 Performs
7/17/2015
arithmetic calculations and logic operations
Md. Manzoor Murshed
10
1
Operating System Software
Manages computer and its peripheral
devices
 Allows communication between user and
computer
 Examples

–
–
–
–
Windows 95
DOS
OS/2
UNIX
7/17/2015
Md. Manzoor Murshed
11
1
Application Software
 Word
processors
 Spreadsheets
 Databases
 Graphics programs
 Programming languages
7/17/2015
Md. Manzoor Murshed
12
1A Brief History of Programming
Languages
 Machine
languages
 Assembly languages
 High-level procedure-oriented
languages
 Object-oriented languages
7/17/2015
Md. Manzoor Murshed
13
1
Computer Program
A computer program is a set of
instructions a programmer writes to tell a
computer what to do.
 In Low level language, commands are
written as strings of binary numbers, 0's
and 1's. Such programs are difficult for
humans to read and to create, but very
"easy" for computers
 high-level languages are easy for
humans to read, but impossible for
machines

7/17/2015
Md. Manzoor Murshed
14
1
Machine Languages
 Are
based on the binary number
system
 Use combination of 0s and 1s to
communicate directly with the
computer
 Are tedious and error-prone; require
highly trained programmers
7/17/2015
Md. Manzoor Murshed
15
1
7/17/2015
Machine Languages
Md. Manzoor Murshed
16
1
Assembly Languages
 Allow
programmers to use
mnemonics in place of 0s and 1s in
the program
 Require an assembler (a program to
convert assembly instructions into
machine code)
 Are easier to write than machine
language, but still tedious and
require highly trained programmers
7/17/2015
Md. Manzoor Murshed
17
1
7/17/2015
Assembly Languages
Md. Manzoor Murshed
18
1High-Level Procedure-Oriented
Languages
Allow programmers to use instructions
that more closely resemble English
 View a problem solution as a set of
ordered steps (correct sequence is critical)
 Use top-down design approach
 Require a compiler to translate the
program into machine language
 Do not require a great amount of technical
expertise to write simple programs
 Examples: Java, COBOL, BASIC, Pascal, C

7/17/2015
Md. Manzoor Murshed
19
1High-Level Procedure-Oriented
Languages
7/17/2015
Md. Manzoor Murshed
20
1
Object-Oriented Languages
View a problem solution as a set of
interacting objects
 Use object-oriented design methodology
 Require a compiler to translate high-level
instructions into machine code
 Examples

– java
– C++
– Visual Basic
7/17/2015
Md. Manzoor Murshed
21
1
Object-Oriented Languages
7/17/2015
Md. Manzoor Murshed
22
1
Advantages of
Object-Oriented Languages
 Allow
programmer to use familiar
objects to solve problems
 Because each object is viewed as an
independent unit, an object can be
used in more than one application,
with little or no modification
7/17/2015
Md. Manzoor Murshed
23
1
OOP Terminology
 OOP
 Encapsulation
 OOD
 Abstraction
 Object
 Hidden/exposed
 Attributes
 Inheritance
(data)
and behaviors
 Class
 Instance
7/17/2015
(derived class
and base class)
Md. Manzoor Murshed
24
1
7/17/2015
Illustration of OOP Terms
Md. Manzoor Murshed
25
1
Lesson A Summary
 Components
of a microcomputer
system
 Relationship between hardware and
software
 History of programming languages
 Terminology used in object-oriented
languages
7/17/2015
Md. Manzoor Murshed
26
Lesson B
An Introduction to Control
Structures
7/17/2015
Md. Manzoor Murshed
27
1
Lesson B Objectives
 Understand
the sequence, selection,
and repetition structures
 Demonstrate the sequence,
selection, and repetition structures
7/17/2015
Md. Manzoor Murshed
28
1
Defining Control Structures
 Control
the flow of a program’s logic
 Also called logic structures
 Three basic structures
– Sequence
– Selection
– Repetition
7/17/2015
Md. Manzoor Murshed
29
1
The Sequence Structure
 Directs
the computer to process the
instructions, one after another, in the
order listed in the program
 Are found in every program
 Algorithm
– Step-by-step instructions to solve a
problem
7/17/2015
Md. Manzoor Murshed
30
1
7/17/2015
The Sequence Structure
Md. Manzoor Murshed
31
1
The Repetition Structure
 Directs
the computer to repeat one
or more instructions until some
condition is met
7/17/2015
Md. Manzoor Murshed
32
1
7/17/2015
The Repetition Structure
Md. Manzoor Murshed
33
1
The Selection Structure
 Directs
the computer to make a
decision, and then select an
appropriate action based on that
decision
 Also called the decision structure
7/17/2015
Md. Manzoor Murshed
34
1
7/17/2015
The Selection Structure
Md. Manzoor Murshed
35
1
Lesson B Summary
 Control
structures
– Sequence structure
– Repetition structure
– Selection (decision) structure
7/17/2015
Md. Manzoor Murshed
36
1
Philosopher Rube Goldberg Predicted
Software Methodology in 1928
7/17/2015
Md. Manzoor Murshed
37
1
Professor Butts takes a drink of strange gin and evolves an invention for opening
the garage door without getting out of the car:
Drive auto bumper (A) against mallet (B), pushing it down and exploding cap (C),
frightening rabbit (D), who runs toward his burrow (E) pulling string (F) which
discharges pistol (G). The bullet penetrates can (H), from which the water drips
into aquarium (I). As the tide rises in the aquarium it elevates the floating cork –
upright (J), which pushes up end of see-saw (K) causing flea (L) to lose its balance
and fall on Gedunk (?) hound’s tail (M) who wakes up and chases his tail round
and round causing platform (N) to spin and turn on faucet (O). Water runs through
hose (P), starting revolving lawn sprinkler (Q) on which rope (R) winds itself,
opening garage door.
Of course, if you wish, you can drive right through the door, and then there won’t
be any obstruction left to bother you in the future.
7/17/2015
Md. Manzoor Murshed
38