Chapter 1
Chapter 1
Objectives (contd.)
Explain the sequence, selection, and repetition
structures
Write simple algorithms using the sequence,
selection, and repetition structures
Programming a Computer
Programs are the directions given to computers
Programmers are the people who write computer
programs
Programming Languages enable programmers to
communicate with the computer
Popular languages: C++, Visual Basic, C#, Java
Employment Opportunities
Computer software engineer: designs an
appropriate solution to a users problem
Computer programmer: codes a computer solution
Coding is the process of translating a computer
solution into a language a computer can
understand
Some positions call for both engineering and
programming
Machine Languages
The first programmers had to write the program
instructions using only combinations of 0s and 1s
Example: 00101 10001 10000
Assembly Languages
Assembly languages simplify programmers job
Can use mnemonics instead of 0s and 1s
Example: ADD bx, ax
High-Level Languages
High-level languages allow programmer to use
English-like instructions
Example: grossPay = hours * rate
High-level languages are more machine independent
Programs written in a high-level language can be used
on many different types of computers
10
11
Control Structures
Programs are written using three basic structures
Sequence
Used in every program you write
Repetition
Used in most programs you write
Selection
Used in most programs you write
12
13
14
15
16
17
18
19
20
Figure 1-5 Algorithm showing the modified condition in the repetition structure
21
Summary
Programs are step-by-step instructions that tell a
computer how to perform a task
Programmers use programming languages to
communicate with the computer
First programming languages were machine
languages: 0s and 1s (machine code)
Next came assembly languages, which allowed for
mnemonics
High-level languages can be used to create
procedure-oriented programs or object-oriented
programs
An Introduction to Programming with C++, Sixth Edition
22
Summary (contd.)
Algorithm: step-by-step instructions that
accomplish a task (not written in a programming
language)
Algorithms contain one or more of the following
control structures: sequence, selection, and
repetition
23
Summary (contd.)
Selection structure: directs the computer to make a
decision and then to select an appropriate action
based on that decision
Repetition structure: repeat one or more
instructions until some condition is met
24
25
26
27