Overview of Computers and Programming
Overview of Computers and Programming
Overview of Computers and Programming
● Computer systems
● Simple program logic
● The program development cycle
● Pseudocode statements and flowchart symbols
● Programming and user environments
● The evolution of programming models
2
1.1 Understanding Computer Systems
● Computer system
– Combination of all the components required to process and store
data using a computer
● Hardware
– Equipment associated with a computer
● Software
– Computer instructions
– Tells the hardware what to do
– Programs
●
Instructions written by programmers
3
Understanding Computer Systems
– Output
● Resulting information that is sent to a printer, a monitor, or
storage devices after processing
● Programming language
– Used to write computer instructions
– Examples
● Visual Basic, C#, C++, or Java
● Syntax
– Rules governing word usage and punctuation
5
Understanding Computer Systems
●
Computer memory
– Computer’s temporary, internal storage – random access
memory (RAM)
– Volatile memory – lost when the power is of
●
Permanent storage devices
– Nonvolatile memory
●
Compiler or interpreter
– Translates source code into machine language (binary language)
statements called object code
– Checks for syntax errors
6
1.2 Understanding Simple Program Logic
●
Program executes or runs
– Input will be accepted, some processing will occur, and results will be
output
●
Programs with syntax errors cannot execute
●
Logical errors
– Errors in program logic produce incorrect output
●
Logic of the computer program
– Sequence of specific instructions in specific order
●
Variable
– Named memory location whose value can vary
7
Understanding Simple Program Logic
8
1.3 The Program Development Cycle
●
Understand the problem
●
Plan the logic
●
Code the program
●
Use software (a compiler or interpreter) to translate the
program into machine language
●
Test the program
●
Put the program into production
●
Maintain the program
9
The Program Development Cycle
10
Understanding the Problem
11
Planning the Logic
● Developing an algorithm
● Heart of the programming process
●
Most common planning tools
– Flowcharts
– Pseudocode
● Desk-checking
– Walking through a program’s logic on paper before you
actually write the program
12
Coding the Program
13
Using Software to Translate the Program
into Machine Language
●
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
– Might need to recompile the code several times
14
Creating an Executable Program
15
Testing the Program
●
Logical error
– Results when a syntactically correct statement, but the
wrong one for the current context, is used
●
Test
– Execute the program with some sample data to see
whether the results are logically correct
●
Debugging is the process of finding and correcting
program errors
●
Programs should be tested with many sets of data
16
Putting the Program into Production
17
Maintaining the Program
● Maintenance
– Making changes after the program is put into production
● Common first programming job
– Maintaining previously written programs
● Make changes to existing programs
– Repeat the development cycle
18
1.4 Using Pseudocode Statements and
Flowchart Symbols
● Pseudocode
– English-like representation of the logical steps it takes to
solve a problem
● Flowchart
– Pictorial representation of the logical steps it takes to
solve a problem
19
Flowchart and Pseudocode of Program that
Doubles a Number
20
Writing Pseudocode
21
Drawing Flowcharts
●
Create a flowchart
– Draw geometric shapes that contain the individual statements
– Connect shapes with arrows
●
Input symbol
– Indicates input operation
– Parallelogram
●
Processing symbol
– Contains processing statements such as arithmetic
– Rectangle
22
Drawing Flowcharts
●
Output symbol
– Represents output statements
– Parallelogram
●
Flowlines
– Arrows that connect steps
●
Terminal symbols
– Start/stop symbols
– Shaped like a racetrack
– Also called lozenges
23
Repeating Instructions
24
Flowchart of iInfinite Number-Doubling
Program
25
Using a Sentinel Value to End a Program
●
Making a decision
– Testing a value
– Decision symbol
●
Diamond shape
●
Dummy value
– Data-entry value that the user will never need
– Sentinel value
●
eof (“end of file”)
– Marker at the end of a file that automatically acts as a sentinel
26
Flowchart of Number-Doubling Program with
Sentinel Value of 0
27
Flowchart Using eof
28
1.5 Understanding Programming and User
Environments
●
Many options for programming and user environments
– Planning
●
Flowchart
●
Pseudocode
– Coding
●
Text editors
– Executing
●
Input from keyboard, mouse, microphone
– Outputting
●
Text, images, sound
29
Understanding Programming Environments
30
A C# Number-Doubling Program in Visual
Studio
31
Understanding User Environments
● Command line
– Location on your computer screen where you type text
entries to communicate with the computer’s operating
system
● Graphical user interface (GUI)
– Allows users to interact with a program in a graphical
environment
32
Executing a Number-Doubling Program
in a Command-Line Environment
33
Executing a Number-Doubling Program
in a GUI Environment
34
1.6 Understanding the Evolution of
Programming Models
35
Understanding the Evolution of Programming
Models
36
1.7 Summary
●
Hardware and software accomplish input, processing, and
output
●
Logic must be developed correctly
●
Logical errors are much more dificult to locate than syntax
errors
●
Use flowcharts, pseudocode charts to plan the logic
●
Avoid infinite loops by testing for a sentinel value
●
Use a text editor or an IDE to enter your program
statements
37
1.8 Programming Exercises