Programming Logic and Design Sixth Edition Chapter 1 An Overview of Computers and Programming
Programming Logic and Design Sixth Edition Chapter 1 An Overview of Computers and Programming
Programming Logic & Design, Sixth Edition 3 Programming Logic & Design, Sixth Edition 4
Programming Logic & Design, Sixth Edition 5 Programming Logic & Design, Sixth Edition 6
1
Understanding the Program
Understanding Simple Program Logic
Development Cycle
• Program with syntax errors cannot execute • Program development cycle
• Logical errors – Understand the problem
– Errors in program logic – Plan the logic
– Produce incorrect output as a result – Code the program
• Logic of the computer program – Use software (a compiler or interpreter) to translate
– Sequence of specific instructions in specific order the program into machine language
– Test the program
• Variable
– Put the program into production
– Named memory location whose value can vary
– Maintain the program
Programming Logic & Design, Sixth Edition 7 Programming Logic & Design, Sixth Edition 8
Programming Logic & Design, Sixth Edition 9 Programming Logic & Design, Sixth Edition 10
Programming Logic & Design, Sixth Edition 11 Programming Logic & Design, Sixth Edition 12
2
Using Software to Translate the
Using Software to Translate the
Program into Machine Language
Program into Machine Language
(continued)
• Translator program
– Compiler or interpreter
– Changes the programmer’s English-like high-level
programming language into the low-level
machine language
• Syntax error
– Misuse of a language’s grammar rules
– Programmer corrects listed syntax errors
Figure 1-2 Creating an executable program
– Might need to recompile the code several times
Programming Logic & Design, Sixth Edition 13 Programming Logic & Design, Sixth Edition 14
Programming Logic & Design, Sixth Edition 15 Programming Logic & Design, Sixth Edition 16
Programming Logic & Design, Sixth Edition 17 Programming Logic & Design, Sixth Edition 18
3
Writing Pseudocode Writing Pseudocode (continued)
Programming Logic & Design, Sixth Edition 19 Programming Logic & Design, Sixth Edition 20
4
Repeating Instructions (continued) Repeating Instructions (continued)
• Loop
– Repetition of a series of steps
• Infinite loop
– Repeating flow of logic with no end
Programming Logic & Design, Sixth Edition 25 Programming Logic & Design, Sixth Edition 26
Programming Logic & Design, Sixth Edition 29 Programming Logic & Design, Sixth Edition 30
5
Understanding Programming Understanding Programming
Environments Environments (continued)
• Use a keyboard to type program statements into an
editor
– Plain text editor
• Similar to a word processor but without as many
features
– Text editor that is part of an integrated
development environment (IDE)
• Software package that provides an editor, compiler,
and other programming tools
Programming Logic & Design, Sixth Edition 31 Programming Logic & Design, Sixth Edition 32
Programming Logic & Design, Sixth Edition 33 Programming Logic & Design, Sixth Edition 34
Programming Logic & Design, Sixth Edition 35 Programming Logic & Design, Sixth Edition 36
6
Understanding the Evolution
Summary
of Programming Models (continued)
• Major models or paradigms used by programmers • Computer programming
– Procedural programming – Requires specific syntax
• Focuses on the procedures that programmers create – Must develop correct logic
– Object-oriented programming • Programmer’s job
• Focuses on objects, or “things,” and describes their – Understanding the problem, planning the logic,
features (or attributes) and their behaviors coding the program, translating the program into
– Major difference machine language, testing the program, putting the
• Focus the programmer takes during the earliest program into production, and maintaining it
planning stages of a project
• Procedural and object-oriented programmers
approach problems differently
Programming Logic & Design, Sixth Edition 37 Programming Logic & Design, Sixth Edition 38