SlideShare a Scribd company logo
1 of 30
Download to read offline
Introduction to Programming in C++
Eight Edition
Lesson 2:
Beginning the Problem-Solving Process
An Introduction to Programming with C++, Eight Edition
• Explain the problem-solving process used to create a
computer program
• Analyze a problem
• Complete an IPO chart
• Plan an algorithm using pseudocode and flowcharts
• Desk-check an algorithm
Objectives
2
An Introduction to Programming with C++, Eight Edition
• First step in solving a problem: analyze it
– Example: paying and mailing a bill
• Next, you plan, review, implement, and evaluate the
solution
• After this, it may be necessary to modify the solution
Solving Everyday Problems
3
An Introduction to Programming with C++, Eight Edition
Solving Everyday Problems (cont’d.)
4
Figure 2-1 Summary of the analysis and planning steps for
the bill paying problem
An Introduction to Programming with C++, Eight Edition
Solving Everyday Problems (cont’d.)
5
Figure 2-2 Modified algorithm for the bill paying problem
An Introduction to Programming with C++, Eight Edition
• A similar process to everyday problem solving is used
to create computer programs
• A computer program is a solution implemented on a
computer
• There are six steps to creating a computer solution to a
problem
Creating Computer Solutions to
Problems
6
An Introduction to Programming with C++, Eight Edition
Creating Computer Solutions to
Problems (cont’d.)
7
Figure 2-3 How to create a computer solution to a
problem
An Introduction to Programming with C++, Eight Edition
• It is essential to understand a problem before creating a
solution to it
• Analyze a problem to:
– Determine the goal of solving it (Output)
– Determine the items needed to achieve that goal (Input)
• Always search first for the output
Step 1−Analyzing the Problem
8
An Introduction to Programming with C++, Eight Edition
Step 1−Analyzing the Problem
(cont’d.)
9
Figure 2-4 Problem specification for Addison O’Reilly
An Introduction to Programming with C++, Eight Edition
• Some programmers use an IPO chart to organize and
summarize the results of a problem analysis
– IPO: Input, processing, and output
Step 1−Analyzing the Problem
(cont’d.)
10
Figure 2-5 Partially completed IPO chart
showing the input and output items
An Introduction to Programming with C++, Eight Edition
• Several readings of the problem may be necessary to
fully understand the problem
• Cross out irrelevant information in the problem
description
Hints for Analyzing Problems
11
Figure 2-6 Problem specification with
unimportant information crossed out
An Introduction to Programming with C++, Eight Edition
• Some problem specifications contain incomplete
information
Hints for Analyzing Problems (cont’d.)
12
Figure 2-7 Problem specification that
does not contain enough information
An Introduction to Programming with C++, Eight Edition
• Distinguish between information that is missing and
information that is implied
Hints for Analyzing Problems (cont’d.)
13
Figure 2-8 Problem specification in which
the input is not explicitly stated
An Introduction to Programming with C++, Eight Edition
• Algorithm: set of instructions that will transform the
problem’s input into its output
– Record in the Processing column of the IPO chart
– Can be written as pseudocode or a flowchart
• Pseudocode: tool programmers use to help plan an
algorithm
– Short English statements
– Not standardized
– Not understandable by a computer
Step 2−Planning the Algorithm
14
An Introduction to Programming with C++, Eight Edition
Step 2−Planning the Algorithm (cont’d.)
15
Figure 2-9 Problem specification and IPO
chart for the Addison O’Reilly problem
An Introduction to Programming with C++, Eight Edition
• Flowcharts are also used to plan an algorithm
– Use standardized symbols
– Symbols connected with flowlines
– Oval: start/stop symbol
• Represents beginning and end of algorithm
– Rectangle: process symbol
• Represents tasks such as calculations
– Parallelogram: input/output symbol
• Represents I/O tasks
Step 2−Planning the Algorithm (cont’d.)
16
An Introduction to Programming with C++, Eight Edition
Step 2−Planning the Algorithm (cont’d.)
17
Figure 2-10 Figure 2-9’s algorithm in flowchart form
An Introduction to Programming with C++, Eight Edition
Step 2−Planning the Algorithm (cont’d.)
18
Figure 2-11 A different solution to the
Addison O’Reilly problem (pseudocode)
An Introduction to Programming with C++, Eight Edition
» Processing item: an intermediate value
(neither input nor output) the algorithm
uses to transform input into output
Step 2−Planning the Algorithm (cont’d.)
19
Figure 2-11 A different solution to the
Addison O’Reilly problem (flowchart)
An Introduction to Programming with C++, Eight Edition
• Desk-checking an algorithm verifies that it is correct
– Refers to checking an algorithm by hand, rather than
with a computer
– Also called hand-tracing
• Choose sample data and manually compute the
expected output value
• Creating a desk-check table can be helpful
Step 3−Desk-Checking the Algorithm
20
An Introduction to Programming with C++, Eight Edition
Step 3−Desk-Checking the Algorithm
(cont’d.)
21
Figure 2-12 Manual cost calculation for the first desk-check
An Introduction to Programming with C++, Eight Edition
Step 3−Desk-Checking the Algorithm (cont’d.)
22
Figure 2-13 Addison O’Reilly solution
and partially completed desk-check table
An Introduction to Programming with C++, Eight Edition
Step 3−Desk-Checking the Algorithm (cont’d.)
23
An Introduction to Programming with C++, Eight Edition
Step 3−Desk-Checking the Algorithm (cont’d.)
24
An Introduction to Programming with C++, Eight Edition
Step 3−Desk-Checking the Algorithm
(cont’d.)
25
An Introduction to Programming with C++, Eight Edition
• Valid data: data that the algorithm is expecting the
user to enter
• Invalid data: data that the algorithm is not expecting the
user to enter
• You should test an algorithm with invalid data
– Users may make mistakes when entering data
Step 3−Desk-Checking the Algorithm
(cont’d.)
26
An Introduction to Programming with C++, Eight Edition
The Gas Mileage Problem
27
An Introduction to Programming with C++, Eight Edition
The Gas Mileage Problem (cont’d.)
28
An Introduction to Programming with C++, Eight Edition
• Then desk-check the algorithm
The Gas Mileage Problem (cont’d.)
29
Figure 2-23 Desk-check table for the gas mileage problem
An Introduction to Programming with C++, Eight Edition
The End ♥ ♥ ♥
30

More Related Content

What's hot

Programming in c (importance of c)
Programming in c (importance of c)Programming in c (importance of c)
Programming in c (importance of c)ViswanathanS21
 
test(3)arithmetic in c
test(3)arithmetic in ctest(3)arithmetic in c
test(3)arithmetic in cJaya Malathy
 
Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14IIUM
 
Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14IIUM
 
Data flow model -Lecture-4
Data flow model -Lecture-4Data flow model -Lecture-4
Data flow model -Lecture-4Dr.YNM
 
Verilog operators
Verilog operatorsVerilog operators
Verilog operatorsDr.YNM
 
9781285852744 ppt ch12
9781285852744 ppt ch129781285852744 ppt ch12
9781285852744 ppt ch12Terry Yoast
 
Issues in design_of_code_generator
Issues in design_of_code_generatorIssues in design_of_code_generator
Issues in design_of_code_generatorvinithapanneer
 
CIS110 Computer Programming Design Chapter (6)
CIS110 Computer Programming Design Chapter  (6)CIS110 Computer Programming Design Chapter  (6)
CIS110 Computer Programming Design Chapter (6)Dr. Ahmed Al Zaidy
 
Unit I - Evaluation of expression
Unit I - Evaluation of expressionUnit I - Evaluation of expression
Unit I - Evaluation of expressionDrkhanchanaR
 
Algorithm and c language
Algorithm and c languageAlgorithm and c language
Algorithm and c languagekamalbeydoun
 
9781285852744 ppt ch08
9781285852744 ppt ch089781285852744 ppt ch08
9781285852744 ppt ch08Terry Yoast
 
Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computerKamal Acharya
 
Data structures algorithms basics
Data structures   algorithms basicsData structures   algorithms basics
Data structures algorithms basicsayeshasafdar8
 

What's hot (20)

Programming in c (importance of c)
Programming in c (importance of c)Programming in c (importance of c)
Programming in c (importance of c)
 
test(3)arithmetic in c
test(3)arithmetic in ctest(3)arithmetic in c
test(3)arithmetic in c
 
Chapter 02 - Problem Solving
Chapter 02 - Problem SolvingChapter 02 - Problem Solving
Chapter 02 - Problem Solving
 
Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14
 
Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14Csc1100 lecture03 ch03-pt2-s14
Csc1100 lecture03 ch03-pt2-s14
 
Data flow model -Lecture-4
Data flow model -Lecture-4Data flow model -Lecture-4
Data flow model -Lecture-4
 
Verilog operators
Verilog operatorsVerilog operators
Verilog operators
 
Ch02
Ch02Ch02
Ch02
 
9781285852744 ppt ch12
9781285852744 ppt ch129781285852744 ppt ch12
9781285852744 ppt ch12
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Issues in design_of_code_generator
Issues in design_of_code_generatorIssues in design_of_code_generator
Issues in design_of_code_generator
 
CIS110 Computer Programming Design Chapter (6)
CIS110 Computer Programming Design Chapter  (6)CIS110 Computer Programming Design Chapter  (6)
CIS110 Computer Programming Design Chapter (6)
 
Unit I - Evaluation of expression
Unit I - Evaluation of expressionUnit I - Evaluation of expression
Unit I - Evaluation of expression
 
Algorithm and c language
Algorithm and c languageAlgorithm and c language
Algorithm and c language
 
9781285852744 ppt ch08
9781285852744 ppt ch089781285852744 ppt ch08
9781285852744 ppt ch08
 
Ppl
PplPpl
Ppl
 
Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computer
 
Lesson 10
Lesson 10Lesson 10
Lesson 10
 
Data structures algorithms basics
Data structures   algorithms basicsData structures   algorithms basics
Data structures algorithms basics
 

Similar to Lesson 2 beginning the problem solving process

Computer Programming
Computer ProgrammingComputer Programming
Computer ProgrammingBurhan Fakhar
 
Introduction to problem solving in c++
Introduction to problem solving in c++Introduction to problem solving in c++
Introduction to problem solving in c++Online
 
Basic of c++ programming
Basic of c++ programmingBasic of c++ programming
Basic of c++ programmingTalha Mughal
 
UoN-Lec_12_Control_Structure.pdf
UoN-Lec_12_Control_Structure.pdfUoN-Lec_12_Control_Structure.pdf
UoN-Lec_12_Control_Structure.pdfmadihamaqbool6
 
9781285852744 ppt ch01
9781285852744 ppt ch019781285852744 ppt ch01
9781285852744 ppt ch01Terry Yoast
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithmDHANIK VIKRANT
 
8.2 approach in problem solving (9 hour)
8.2 approach in problem solving (9 hour)8.2 approach in problem solving (9 hour)
8.2 approach in problem solving (9 hour)Fiqry Suryansyah
 
9781285852744 ppt ch02
9781285852744 ppt ch029781285852744 ppt ch02
9781285852744 ppt ch02Terry Yoast
 
9781285852751 ppt c++
9781285852751 ppt c++9781285852751 ppt c++
9781285852751 ppt c++umair khan
 
ch01_an overview of computers and programming languages
ch01_an overview of computers and programming languagesch01_an overview of computers and programming languages
ch01_an overview of computers and programming languagesLiemLe21
 
Computer graphics 9068
Computer graphics  9068Computer graphics  9068
Computer graphics 90681061992
 
chapter1-161229182113 (1).pdf
chapter1-161229182113 (1).pdfchapter1-161229182113 (1).pdf
chapter1-161229182113 (1).pdfBernardVelasco1
 
Review chapter 1 2-3
Review chapter 1 2-3Review chapter 1 2-3
Review chapter 1 2-3ahmed22dg
 
CIS110 Computer Programming Design Chapter (1)
CIS110 Computer Programming Design Chapter  (1)CIS110 Computer Programming Design Chapter  (1)
CIS110 Computer Programming Design Chapter (1)Dr. Ahmed Al Zaidy
 
Technical Drafting Module 6
Technical Drafting Module 6Technical Drafting Module 6
Technical Drafting Module 6DepEd
 

Similar to Lesson 2 beginning the problem solving process (20)

Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
 
Introduction to problem solving in c++
Introduction to problem solving in c++Introduction to problem solving in c++
Introduction to problem solving in c++
 
Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
 
Basic of c++ programming
Basic of c++ programmingBasic of c++ programming
Basic of c++ programming
 
Programing Fundamental
Programing FundamentalPrograming Fundamental
Programing Fundamental
 
UoN-Lec_12_Control_Structure.pdf
UoN-Lec_12_Control_Structure.pdfUoN-Lec_12_Control_Structure.pdf
UoN-Lec_12_Control_Structure.pdf
 
9781285852744 ppt ch01
9781285852744 ppt ch019781285852744 ppt ch01
9781285852744 ppt ch01
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
 
8.2 approach in problem solving (9 hour)
8.2 approach in problem solving (9 hour)8.2 approach in problem solving (9 hour)
8.2 approach in problem solving (9 hour)
 
9781285852744 ppt ch02
9781285852744 ppt ch029781285852744 ppt ch02
9781285852744 ppt ch02
 
9781285852751 ppt c++
9781285852751 ppt c++9781285852751 ppt c++
9781285852751 ppt c++
 
ch01_an overview of computers and programming languages
ch01_an overview of computers and programming languagesch01_an overview of computers and programming languages
ch01_an overview of computers and programming languages
 
Cs 1114 - lecture-2
Cs 1114 - lecture-2Cs 1114 - lecture-2
Cs 1114 - lecture-2
 
Computer graphics 9068
Computer graphics  9068Computer graphics  9068
Computer graphics 9068
 
chapter1-161229182113 (1).pdf
chapter1-161229182113 (1).pdfchapter1-161229182113 (1).pdf
chapter1-161229182113 (1).pdf
 
C++.ppt
C++.pptC++.ppt
C++.ppt
 
Review chapter 1 2-3
Review chapter 1 2-3Review chapter 1 2-3
Review chapter 1 2-3
 
CP Handout#1
CP Handout#1CP Handout#1
CP Handout#1
 
CIS110 Computer Programming Design Chapter (1)
CIS110 Computer Programming Design Chapter  (1)CIS110 Computer Programming Design Chapter  (1)
CIS110 Computer Programming Design Chapter (1)
 
Technical Drafting Module 6
Technical Drafting Module 6Technical Drafting Module 6
Technical Drafting Module 6
 

More from MLG College of Learning, Inc (20)

PC111.Lesson2
PC111.Lesson2PC111.Lesson2
PC111.Lesson2
 
PC111.Lesson1
PC111.Lesson1PC111.Lesson1
PC111.Lesson1
 
PC111-lesson1.pptx
PC111-lesson1.pptxPC111-lesson1.pptx
PC111-lesson1.pptx
 
PC LEESOON 6.pptx
PC LEESOON 6.pptxPC LEESOON 6.pptx
PC LEESOON 6.pptx
 
PC 106 PPT-09.pptx
PC 106 PPT-09.pptxPC 106 PPT-09.pptx
PC 106 PPT-09.pptx
 
PC 106 PPT-07
PC 106 PPT-07PC 106 PPT-07
PC 106 PPT-07
 
PC 106 PPT-01
PC 106 PPT-01PC 106 PPT-01
PC 106 PPT-01
 
PC 106 PPT-06
PC 106 PPT-06PC 106 PPT-06
PC 106 PPT-06
 
PC 106 PPT-05
PC 106 PPT-05PC 106 PPT-05
PC 106 PPT-05
 
PC 106 Slide 04
PC 106 Slide 04PC 106 Slide 04
PC 106 Slide 04
 
PC 106 Slide no.02
PC 106 Slide no.02PC 106 Slide no.02
PC 106 Slide no.02
 
pc-106-slide-3
pc-106-slide-3pc-106-slide-3
pc-106-slide-3
 
PC 106 Slide 2
PC 106 Slide 2PC 106 Slide 2
PC 106 Slide 2
 
PC 106 Slide 1.pptx
PC 106 Slide 1.pptxPC 106 Slide 1.pptx
PC 106 Slide 1.pptx
 
Db2 characteristics of db ms
Db2 characteristics of db msDb2 characteristics of db ms
Db2 characteristics of db ms
 
Db1 introduction
Db1 introductionDb1 introduction
Db1 introduction
 
Lesson 3.2
Lesson 3.2Lesson 3.2
Lesson 3.2
 
Lesson 3.1
Lesson 3.1Lesson 3.1
Lesson 3.1
 
Lesson 1.6
Lesson 1.6Lesson 1.6
Lesson 1.6
 
Lesson 3.2
Lesson 3.2Lesson 3.2
Lesson 3.2
 

Recently uploaded

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 

Recently uploaded (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 

Lesson 2 beginning the problem solving process

  • 1. Introduction to Programming in C++ Eight Edition Lesson 2: Beginning the Problem-Solving Process
  • 2. An Introduction to Programming with C++, Eight Edition • Explain the problem-solving process used to create a computer program • Analyze a problem • Complete an IPO chart • Plan an algorithm using pseudocode and flowcharts • Desk-check an algorithm Objectives 2
  • 3. An Introduction to Programming with C++, Eight Edition • First step in solving a problem: analyze it – Example: paying and mailing a bill • Next, you plan, review, implement, and evaluate the solution • After this, it may be necessary to modify the solution Solving Everyday Problems 3
  • 4. An Introduction to Programming with C++, Eight Edition Solving Everyday Problems (cont’d.) 4 Figure 2-1 Summary of the analysis and planning steps for the bill paying problem
  • 5. An Introduction to Programming with C++, Eight Edition Solving Everyday Problems (cont’d.) 5 Figure 2-2 Modified algorithm for the bill paying problem
  • 6. An Introduction to Programming with C++, Eight Edition • A similar process to everyday problem solving is used to create computer programs • A computer program is a solution implemented on a computer • There are six steps to creating a computer solution to a problem Creating Computer Solutions to Problems 6
  • 7. An Introduction to Programming with C++, Eight Edition Creating Computer Solutions to Problems (cont’d.) 7 Figure 2-3 How to create a computer solution to a problem
  • 8. An Introduction to Programming with C++, Eight Edition • It is essential to understand a problem before creating a solution to it • Analyze a problem to: – Determine the goal of solving it (Output) – Determine the items needed to achieve that goal (Input) • Always search first for the output Step 1−Analyzing the Problem 8
  • 9. An Introduction to Programming with C++, Eight Edition Step 1−Analyzing the Problem (cont’d.) 9 Figure 2-4 Problem specification for Addison O’Reilly
  • 10. An Introduction to Programming with C++, Eight Edition • Some programmers use an IPO chart to organize and summarize the results of a problem analysis – IPO: Input, processing, and output Step 1−Analyzing the Problem (cont’d.) 10 Figure 2-5 Partially completed IPO chart showing the input and output items
  • 11. An Introduction to Programming with C++, Eight Edition • Several readings of the problem may be necessary to fully understand the problem • Cross out irrelevant information in the problem description Hints for Analyzing Problems 11 Figure 2-6 Problem specification with unimportant information crossed out
  • 12. An Introduction to Programming with C++, Eight Edition • Some problem specifications contain incomplete information Hints for Analyzing Problems (cont’d.) 12 Figure 2-7 Problem specification that does not contain enough information
  • 13. An Introduction to Programming with C++, Eight Edition • Distinguish between information that is missing and information that is implied Hints for Analyzing Problems (cont’d.) 13 Figure 2-8 Problem specification in which the input is not explicitly stated
  • 14. An Introduction to Programming with C++, Eight Edition • Algorithm: set of instructions that will transform the problem’s input into its output – Record in the Processing column of the IPO chart – Can be written as pseudocode or a flowchart • Pseudocode: tool programmers use to help plan an algorithm – Short English statements – Not standardized – Not understandable by a computer Step 2−Planning the Algorithm 14
  • 15. An Introduction to Programming with C++, Eight Edition Step 2−Planning the Algorithm (cont’d.) 15 Figure 2-9 Problem specification and IPO chart for the Addison O’Reilly problem
  • 16. An Introduction to Programming with C++, Eight Edition • Flowcharts are also used to plan an algorithm – Use standardized symbols – Symbols connected with flowlines – Oval: start/stop symbol • Represents beginning and end of algorithm – Rectangle: process symbol • Represents tasks such as calculations – Parallelogram: input/output symbol • Represents I/O tasks Step 2−Planning the Algorithm (cont’d.) 16
  • 17. An Introduction to Programming with C++, Eight Edition Step 2−Planning the Algorithm (cont’d.) 17 Figure 2-10 Figure 2-9’s algorithm in flowchart form
  • 18. An Introduction to Programming with C++, Eight Edition Step 2−Planning the Algorithm (cont’d.) 18 Figure 2-11 A different solution to the Addison O’Reilly problem (pseudocode)
  • 19. An Introduction to Programming with C++, Eight Edition » Processing item: an intermediate value (neither input nor output) the algorithm uses to transform input into output Step 2−Planning the Algorithm (cont’d.) 19 Figure 2-11 A different solution to the Addison O’Reilly problem (flowchart)
  • 20. An Introduction to Programming with C++, Eight Edition • Desk-checking an algorithm verifies that it is correct – Refers to checking an algorithm by hand, rather than with a computer – Also called hand-tracing • Choose sample data and manually compute the expected output value • Creating a desk-check table can be helpful Step 3−Desk-Checking the Algorithm 20
  • 21. An Introduction to Programming with C++, Eight Edition Step 3−Desk-Checking the Algorithm (cont’d.) 21 Figure 2-12 Manual cost calculation for the first desk-check
  • 22. An Introduction to Programming with C++, Eight Edition Step 3−Desk-Checking the Algorithm (cont’d.) 22 Figure 2-13 Addison O’Reilly solution and partially completed desk-check table
  • 23. An Introduction to Programming with C++, Eight Edition Step 3−Desk-Checking the Algorithm (cont’d.) 23
  • 24. An Introduction to Programming with C++, Eight Edition Step 3−Desk-Checking the Algorithm (cont’d.) 24
  • 25. An Introduction to Programming with C++, Eight Edition Step 3−Desk-Checking the Algorithm (cont’d.) 25
  • 26. An Introduction to Programming with C++, Eight Edition • Valid data: data that the algorithm is expecting the user to enter • Invalid data: data that the algorithm is not expecting the user to enter • You should test an algorithm with invalid data – Users may make mistakes when entering data Step 3−Desk-Checking the Algorithm (cont’d.) 26
  • 27. An Introduction to Programming with C++, Eight Edition The Gas Mileage Problem 27
  • 28. An Introduction to Programming with C++, Eight Edition The Gas Mileage Problem (cont’d.) 28
  • 29. An Introduction to Programming with C++, Eight Edition • Then desk-check the algorithm The Gas Mileage Problem (cont’d.) 29 Figure 2-23 Desk-check table for the gas mileage problem
  • 30. An Introduction to Programming with C++, Eight Edition The End ♥ ♥ ♥ 30