Class3 Notes
Class3 Notes
2
Objectives (continued)
3
Concept Lesson
4
More on the Problem-Solving Process
5
Coding the Algorithm into a Program
6
Assigning Names, Data Types, and
Initial Values to the IPO Items
• To code algorithm, first assign a name to each input,
processing, and output item in IPO chart
– Names can contain only letters, numbers, and _
– Cannot contain punctuation characters or spaces
– Examples:
• raise usually in lowercase letters
• newPay use camel case if name contains multiple words
– Each input/processing/output item must have a data
type
– You may initialize each item
7
Assigning Names, Data Types, and Initial
Values to the IPO Items (continued)
double is a keyword
this is a statement
a stream manipulator
9
Desk-Checking the Program
10
Desk-Checking the Program
(continued)
11
Desk-Checking the Program
(continued)
12
Evaluating and Modifying the Program
14
Creating a C++ Program (continued)
15
Summary
• Fourth step in the problem-solving process is to code
the algorithm into a program
• In C++, you perform standard I/O operations using
streams (sequences of characters)
– cout and cin
– Insertion operator (<<) sends data to output stream
– Extraction operator (>>) gets data from input stream
• After coding the algorithm, you desk-check program
• Final step in the problem-solving process is to
evaluate and modify (if necessary) the program
16
Summary (continued)
• Some programs have errors, called bugs
– Syntax error occurs when an instruction violates one
of the rules of the programming language’s syntax
– Logic error occurs when you enter an instruction that
does not give you the expected results
– You debug to locate and remove errors
• To create and execute a C++ program, you need to
have a text editor and a C++ compiler
– Compiler translates source code into object code
– Linker produces executable file
17
Summary (continued)
18