SlideShare a Scribd company logo
SECTION 2
STAGES OF PROGRAM DEVELOPMENT
 PROBLEM DEFINITION
 ANALYSIS
 DESIGN A SOLUTION USING AN ALGORITHM
 WRITE A COMPUTER PROGRAM
 TEST AND DEBUG THE PROGRAM
 DOCUMENT THE PROGRAM
Problem-
Solving
Phase
Implementation
Phase
PROBLEM SOLVING PHASE:
STEP 1: Define the problem
STEP 2: Find the solution to the problem
STEP 3: Evaluate alternative solutions
STEP 4: Represent the most efficient solution as an
algorithm
STEP 5: Test the algorithm for correctness
STAGE 1: DEFINING THE PROBLEM
Stating what the problem is and what the end result should
be.
A problem should be decomposed into 3 key components:
1. INPUT
2. PROCESS
3. OUTPUT
DEFINING THE PROBLEM
INPUT
(What is given)
OUTPUT
(The expected
output)
PROCESS
(Tasks that
must be
performed)
Example:
 Write a program that enters a student name and date
of birth and calculate the child’s age and write the
name and age of the child.
PROBLEM DEFINITION:
 Required to find the age of a child
 DEFINING DIAGRAM
INPUT PROCESS OUTPUT
1. Student Name Calculate the child’s age 1. Student Name
2. Student DOB From the child’s DOB 2. Student Age
Questions
1. Write a program that is required to read three (3)
numbers, calculate and print their total.
2. Give three integers representing the age of three boys
respectively, write a program to find their average and also
determine the age of the oldest boy.
3. Write a program to enter the base and height of a triangle
and find and print the area.
4. Write a program to read the temperature in degrees Celsius
and convert it to degrees Celsius and Fahrenheit.
PROBLEM DEFINITIONS:
1. Required to find the Total of three numbers.
2. Required to find the average age of 3 boys and the
age of the oldest boy.
3. Required to find the Area of a triangle.
4. Required to find the Fahrenheit equivalent of a
temperature in degrees Celsius.
DEFINING DIAGRAM: QUES. 1
INPUT PROCESS OUTPUT
NUM1 GET NUM1, NUM2,
NUM3
TOTAL/SUM
NUM2 CALCULATE TOTAL
USING NUM1,
NUM2,NUM3
NUM3 DISPLAY TOTAL
QUES. 2
INPUT PROCESS OUTPUT
AGE1 1. Read AGE1, AGE2,
AGE3
1.AVERAGE AGE
AGE2 2. CALCULATE
AVERAGE AGE USING
AGE1, AGE2, AGE3.
2. AGE OF OLDEST BOY
AGE 3 3. FIND AGE OF OLDEST
BOY FROM AGE1, AGE2,
AGE3
4. DISPLAY AVERAGE,
AGE OF OLDEST BOY
QUES. 3
INPUT PROCESS OUTPUT
BASE READ BASE, HEIGHT AREA OF TRIANGLE
HEIGHT CALCULATE AREA
USING BASE AND
HEIGHT
DISPLAY AREA
QUES. 4
INPUT PROCESS OUPUT
DEGREES CELCIUS READ DEGREES
CELCIUS
DEGREES FAHRENHEIT
CALCULATE DEGREES
FAHRENHEIT USING
DEGREES CELCIUS
DISPLAY DEGREES
FAHRENHEIT
ALGORITHMS
 An algorithm is a series of steps to be followed to
perform a task.
An algorithm should be:
1. Precise
2. Unambiguous
3. Finite (i.e. terminate after a given number of steps)
4. Instructions must be in Logical order
Questions
1. Identify which of the options gives the steps in correct sequence:
(a) Get on the bus, get dressed for school, get off the bus at school
(b) Get dressed for school, get off the bus at school, get on the bus
(c) Get off the bus at school, get on the bus, get dressed for school
(d) Get dressed for school, get on the bus, get off the bus at school
2. Consider the following algorithms & identify which one accurately gives the area of a square:
(a) Get length and width
Area = length x width
(b) Get side measurement of square
Area = side x side
(c) Get area of square
Area =Area x 2
(d) Get side measurement of square
Area = side x 4
3. Consider the following algorithm and choose the correct
step to make it complete:
Purchase some ice-cream and toppings
Get ice-cream scoop
Use scoop to place two scoops of ice-cream on cone
Cover with sprinkles
Add a cherry to the top
(a) Eat cake
(b) Go to the cinema
(c) Purchase cone
(d) Enjoy the movie
VARIABLES
 A Variable is a location in memory where data of
different types are stored. When you declare a variable
the computer sets aside a location in memory to store
data.
num1 num2 sum
E.g. var num1, num2, sum: integer;
 A variable can be given a value or a variable can be set
to a specific value.
E.g. num1:= 1
Or the user inputs the value for num1 (1, 2, 3, 5, 90, etc.)
 A variable can hold ONLY one value at a time. If a new
value is entered, the old one is lost.
e.g.
5 is currently being stored in the
num1 memory location with the label,
num1 (variable). If you enter a new
value, say 15 for the variable num1,
the value 5 is replaced by the value
num1 15.
5
15
1)Write a program that is required to read three (3)
numbers, calculate and print their total.
2)Write a program to enter girls’ heights. Calculate the
average height of the girls.
• Underline the variables in your program!
3)Identify all the variables in the program AreaOfSquare.
1. Write an algorithm to find the sum of two numbers
and display the sum.
2. Write an algorithm to enter the name of an item, Cost
Price of an item, the number of items purchased;
calculate the Total Cost of items and display the
name of the item and total cost of the items.
3. Write an algorithm to enter a student’s name, three
marks; calculate the average mark. Display the
student’s name and average mark.
Program AreaOfSquare;
var s, a: integer;
Begin
write(‘Enter length of side:’);
read (s); {store length in s}
a:= s*s; {calculate area; store in a}
writeln; {print a blank line}
writeln(‘Area of square is’, a);
End.
VARIABLE NAMES/Identifiers
The variable name can:
• Start with a letter or underscore
• Be a combination of letters, digits and underscore
• The length of the variable name cannot exceed 31
characters
• No spaces are allowed in the variable names
Exercise:
 Identify the valid and invalid variable names:
R
_XYZ
Alpha;beta
Net Pay
Maxamt
Root1
2hottohandle
DATA TYPES
 Integer
 Real (floating point)
 String
 Boolean (data which can be true or false)
 Character (data consisting of a single character)
Examples of data types:
 Integer:- 3, -59, 0, 1987
 Real:- 3.142, -5.0, 1.16
 Boolean:- True or False
 Character- ‘k’, ‘8’
 String:- ‘Hi there’
ALGORITHMIC STRUCTURE
 Header- Algorithm’s name or title
 Declaration- A brief description of algorithm and
variables used.
 Body- sequence of steps
 Terminator- end statement
PSEUDOCODE
 An outline of a program, written in a form that can
easily be converted into real programming statements.
CONTROL STRUCTURES
 SEQUENCE
 SELECTION
 REPETITION (LOOP)
SEQUENTIAL STRUCTURE
 INPUT STATEMENTS. For example,
A. Get num1, num2
B. Read price
• OUTPUT STATEMENTS. For example,
A. Print Total_Cost
B. Display Average
• Statements with arithmetic operations:
A. Sum = num1 + num2
• Statements that assign values to variables:
A. Count = 0
B. Max = 20
SELECTION STRUCTURE
 IF-THEN-ELSE
A. If (A>B) then
Display A
B. If (age>= 50)
Print “Old”
Else
Print “Young”
REPETITION: LOOP
A. While (price <> 0) do
read price
total = total + price
End while
B. Repeat 10 times
Print “I am good looking”
End Repeat
FLOWCHARTS
 Algorithms can also be expressed as flowcharts. A
flowchart is a pictorial representation of an algorithm.
 A parallelogram- represents the input & output operation.
 A rectangle- used to represent processing/assignment
statements.
 A diamond- represents a decision (if-then-else).
 An elliptical shape- represents terminal indicators.
 Directional arrows- indicate the flow of logic in the
program.
INPUT/OUTPUT
PROCESSING/ASSIGNMENT
DECISION
START/STOP
FLOW OF LOGIC
SEQUENCE
DECISION
 FOR LOOP
REPITITION
WHILE LOOP
REPEAT UNTIL
http://users.evtek.fi/~jaanah/IntroC/DBeech/3gl_flow.htm
ARRAYS
 An array is a special variable where we reserve a series
of locations in memory to store data items of a certain
data type. These related data items are of the same
data type.
DECLARING AN ARRAY
 Example:
var MARKS: Array[1..35] of integer;
Reserved
word
Variable
Name
Group of
35 Data type
MARKS is the name of the entire array. In order to access one data item the
subscript is used.
MARKS
1 2 3 4 5
RESOURCES
EXERCISES

More Related Content

What's hot

Introduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- PythonIntroduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- Python
PriyankaC44
 
Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowcharts
nicky_walters
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
Harshita Yadav
 
System calls
System callsSystem calls
System calls
Bernard Senam
 
Diff between c and c++
Diff between c and c++Diff between c and c++
Diff between c and c++
VishrudhMamidala
 
Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to Pseudocode
Damian T. Gordon
 
Algorithm and pseudocode conventions
Algorithm and pseudocode conventionsAlgorithm and pseudocode conventions
Algorithm and pseudocode conventions
saranyatdr
 
Lecture Note-1: Algorithm and Its Properties
Lecture Note-1: Algorithm and Its PropertiesLecture Note-1: Algorithm and Its Properties
Lecture Note-1: Algorithm and Its Properties
Rajesh K Shukla
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
nitamhaske
 
Database connectivity in python
Database connectivity in pythonDatabase connectivity in python
Database connectivity in python
baabtra.com - No. 1 supplier of quality freshers
 
Evolution of os
Evolution of osEvolution of os
Evolution of os
janani thirupathi
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
satvirsandhu9
 
Algorithmic Notations
Algorithmic NotationsAlgorithmic Notations
Algorithmic Notations
Muhammad Muzammal
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
Tareq Hasan
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
Emertxe Information Technologies Pvt Ltd
 
Case study
Case studyCase study
Case study
Usha Ravichandran
 
Basic Computer Architecture
Basic Computer ArchitectureBasic Computer Architecture
Basic Computer Architecture
Yong Heui Cho
 
Computer system architecture
Computer system architectureComputer system architecture
Computer system architecture
venkateswarlu G
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
Sujith Kumar
 
Instruction format
Instruction formatInstruction format
Instruction format
Sanjeev Patel
 

What's hot (20)

Introduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- PythonIntroduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- Python
 
Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowcharts
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
System calls
System callsSystem calls
System calls
 
Diff between c and c++
Diff between c and c++Diff between c and c++
Diff between c and c++
 
Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to Pseudocode
 
Algorithm and pseudocode conventions
Algorithm and pseudocode conventionsAlgorithm and pseudocode conventions
Algorithm and pseudocode conventions
 
Lecture Note-1: Algorithm and Its Properties
Lecture Note-1: Algorithm and Its PropertiesLecture Note-1: Algorithm and Its Properties
Lecture Note-1: Algorithm and Its Properties
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
 
Database connectivity in python
Database connectivity in pythonDatabase connectivity in python
Database connectivity in python
 
Evolution of os
Evolution of osEvolution of os
Evolution of os
 
Presentation on C++ Programming Language
Presentation on C++ Programming LanguagePresentation on C++ Programming Language
Presentation on C++ Programming Language
 
Algorithmic Notations
Algorithmic NotationsAlgorithmic Notations
Algorithmic Notations
 
Algorithm.ppt
Algorithm.pptAlgorithm.ppt
Algorithm.ppt
 
Python programming : Files
Python programming : FilesPython programming : Files
Python programming : Files
 
Case study
Case studyCase study
Case study
 
Basic Computer Architecture
Basic Computer ArchitectureBasic Computer Architecture
Basic Computer Architecture
 
Computer system architecture
Computer system architectureComputer system architecture
Computer system architecture
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 
Instruction format
Instruction formatInstruction format
Instruction format
 

Viewers also liked

Program design and problem solving techniques
Program design and problem solving techniquesProgram design and problem solving techniques
Program design and problem solving techniques
Dokka Srinivasu
 
Insight & Solving Design Problem with Design Sprint Method
Insight & Solving Design Problem with Design Sprint MethodInsight & Solving Design Problem with Design Sprint Method
Insight & Solving Design Problem with Design Sprint Method
Ngurah Devara Udayana
 
Problem definition and research design workshop
Problem definition and research design workshopProblem definition and research design workshop
Problem definition and research design workshop
António Moniz
 
Problem Solving Techniques For Evolutionary Design
Problem Solving Techniques For Evolutionary DesignProblem Solving Techniques For Evolutionary Design
Problem Solving Techniques For Evolutionary Design
Naresh Jain
 
problem definition
problem definitionproblem definition
problem definition
nuraminramli
 
Java: Class Design Examples
Java: Class Design ExamplesJava: Class Design Examples
Java: Class Design Examples
Tareq Hasan
 
Experiment (XP) Gameboard: How Great Organizations Rapidly Solve Problems, Le...
Experiment (XP) Gameboard: How Great Organizations Rapidly Solve Problems, Le...Experiment (XP) Gameboard: How Great Organizations Rapidly Solve Problems, Le...
Experiment (XP) Gameboard: How Great Organizations Rapidly Solve Problems, Le...
Rod King, Ph.D.
 
OGDC2013_Game design problem solving_Mr Nguyen Chi Hieu
OGDC2013_Game design problem solving_Mr Nguyen Chi HieuOGDC2013_Game design problem solving_Mr Nguyen Chi Hieu
OGDC2013_Game design problem solving_Mr Nguyen Chi Hieu
ogdc
 
Empathy Map and Problem Statement for Design Thinking Action Lab
Empathy Map and Problem Statement for Design Thinking Action LabEmpathy Map and Problem Statement for Design Thinking Action Lab
Empathy Map and Problem Statement for Design Thinking Action Lab
Felipe Lima
 
Design Thinking and Innovation
Design Thinking and InnovationDesign Thinking and Innovation
Design Thinking and Innovation
Ting-Shuo Yo
 
TEXTILE DESIGN AS PROBLEM SOLVING(presentation)
TEXTILE DESIGN AS PROBLEM SOLVING(presentation)TEXTILE DESIGN AS PROBLEM SOLVING(presentation)
TEXTILE DESIGN AS PROBLEM SOLVING(presentation)
Ebenezer Kofi Howard
 
Problem solving and_critical_thinking_eltecs
Problem solving and_critical_thinking_eltecsProblem solving and_critical_thinking_eltecs
Problem solving and_critical_thinking_eltecs
Jamie Hoang
 
Design Thinking & Lean Product Development •How to Identify a Real Problem Th...
Design Thinking & Lean Product Development •How to Identify a Real Problem Th...Design Thinking & Lean Product Development •How to Identify a Real Problem Th...
Design Thinking & Lean Product Development •How to Identify a Real Problem Th...
PHX Startup Week
 
HISTORY OF ARCHITECTURE EDUCATION: POTENTIALS AND LIMITATIONS FOR A BETTER DE...
HISTORY OF ARCHITECTURE EDUCATION: POTENTIALS AND LIMITATIONS FOR A BETTER DE...HISTORY OF ARCHITECTURE EDUCATION: POTENTIALS AND LIMITATIONS FOR A BETTER DE...
HISTORY OF ARCHITECTURE EDUCATION: POTENTIALS AND LIMITATIONS FOR A BETTER DE...
Iman Gawad
 
Communication skills Basic
Communication skills BasicCommunication skills Basic
Communication skills Basic
SachinKabra
 
Critical Thinking, Problem Solving, Decision Making
Critical Thinking, Problem Solving, Decision MakingCritical Thinking, Problem Solving, Decision Making
Critical Thinking, Problem Solving, Decision Making
guestd388be
 
Thinking Tools for Creative Kids An Introduction
Thinking Tools for Creative Kids An IntroductionThinking Tools for Creative Kids An Introduction
Thinking Tools for Creative Kids An Introduction
Bodha Educational Services Pvt. Ltd
 
Design Theory - Lecture 02: Design processes & Problem solving
Design Theory - Lecture 02: Design processes & Problem solvingDesign Theory - Lecture 02: Design processes & Problem solving
Design Theory - Lecture 02: Design processes & Problem solving
Bas Leurs
 
Problem definition /identification in Research
Problem definition /identification in ResearchProblem definition /identification in Research
Problem definition /identification in Research
Shameem Ali
 
Learning Design for Problem-Solving
Learning Design for Problem-SolvingLearning Design for Problem-Solving
Learning Design for Problem-Solving
Global OER Graduate Network
 

Viewers also liked (20)

Program design and problem solving techniques
Program design and problem solving techniquesProgram design and problem solving techniques
Program design and problem solving techniques
 
Insight & Solving Design Problem with Design Sprint Method
Insight & Solving Design Problem with Design Sprint MethodInsight & Solving Design Problem with Design Sprint Method
Insight & Solving Design Problem with Design Sprint Method
 
Problem definition and research design workshop
Problem definition and research design workshopProblem definition and research design workshop
Problem definition and research design workshop
 
Problem Solving Techniques For Evolutionary Design
Problem Solving Techniques For Evolutionary DesignProblem Solving Techniques For Evolutionary Design
Problem Solving Techniques For Evolutionary Design
 
problem definition
problem definitionproblem definition
problem definition
 
Java: Class Design Examples
Java: Class Design ExamplesJava: Class Design Examples
Java: Class Design Examples
 
Experiment (XP) Gameboard: How Great Organizations Rapidly Solve Problems, Le...
Experiment (XP) Gameboard: How Great Organizations Rapidly Solve Problems, Le...Experiment (XP) Gameboard: How Great Organizations Rapidly Solve Problems, Le...
Experiment (XP) Gameboard: How Great Organizations Rapidly Solve Problems, Le...
 
OGDC2013_Game design problem solving_Mr Nguyen Chi Hieu
OGDC2013_Game design problem solving_Mr Nguyen Chi HieuOGDC2013_Game design problem solving_Mr Nguyen Chi Hieu
OGDC2013_Game design problem solving_Mr Nguyen Chi Hieu
 
Empathy Map and Problem Statement for Design Thinking Action Lab
Empathy Map and Problem Statement for Design Thinking Action LabEmpathy Map and Problem Statement for Design Thinking Action Lab
Empathy Map and Problem Statement for Design Thinking Action Lab
 
Design Thinking and Innovation
Design Thinking and InnovationDesign Thinking and Innovation
Design Thinking and Innovation
 
TEXTILE DESIGN AS PROBLEM SOLVING(presentation)
TEXTILE DESIGN AS PROBLEM SOLVING(presentation)TEXTILE DESIGN AS PROBLEM SOLVING(presentation)
TEXTILE DESIGN AS PROBLEM SOLVING(presentation)
 
Problem solving and_critical_thinking_eltecs
Problem solving and_critical_thinking_eltecsProblem solving and_critical_thinking_eltecs
Problem solving and_critical_thinking_eltecs
 
Design Thinking & Lean Product Development •How to Identify a Real Problem Th...
Design Thinking & Lean Product Development •How to Identify a Real Problem Th...Design Thinking & Lean Product Development •How to Identify a Real Problem Th...
Design Thinking & Lean Product Development •How to Identify a Real Problem Th...
 
HISTORY OF ARCHITECTURE EDUCATION: POTENTIALS AND LIMITATIONS FOR A BETTER DE...
HISTORY OF ARCHITECTURE EDUCATION: POTENTIALS AND LIMITATIONS FOR A BETTER DE...HISTORY OF ARCHITECTURE EDUCATION: POTENTIALS AND LIMITATIONS FOR A BETTER DE...
HISTORY OF ARCHITECTURE EDUCATION: POTENTIALS AND LIMITATIONS FOR A BETTER DE...
 
Communication skills Basic
Communication skills BasicCommunication skills Basic
Communication skills Basic
 
Critical Thinking, Problem Solving, Decision Making
Critical Thinking, Problem Solving, Decision MakingCritical Thinking, Problem Solving, Decision Making
Critical Thinking, Problem Solving, Decision Making
 
Thinking Tools for Creative Kids An Introduction
Thinking Tools for Creative Kids An IntroductionThinking Tools for Creative Kids An Introduction
Thinking Tools for Creative Kids An Introduction
 
Design Theory - Lecture 02: Design processes & Problem solving
Design Theory - Lecture 02: Design processes & Problem solvingDesign Theory - Lecture 02: Design processes & Problem solving
Design Theory - Lecture 02: Design processes & Problem solving
 
Problem definition /identification in Research
Problem definition /identification in ResearchProblem definition /identification in Research
Problem definition /identification in Research
 
Learning Design for Problem-Solving
Learning Design for Problem-SolvingLearning Design for Problem-Solving
Learning Design for Problem-Solving
 

Similar to Problem solving and design

Logic Development and Algorithm.
Logic Development and Algorithm.Logic Development and Algorithm.
Logic Development and Algorithm.
NandiniSidana
 
Chapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docxChapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docx
tiffanyd4
 
Problem solving (C++ Programming)
Problem solving (C++ Programming)Problem solving (C++ Programming)
Problem solving (C++ Programming)
Umair Younas
 
Md university cmis 102 week 3 hands
Md university cmis 102 week 3 handsMd university cmis 102 week 3 hands
Md university cmis 102 week 3 hands
eyavagal
 
UNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.pptUNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.ppt
GovindUpadhyay25
 
OverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docxOverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docx
gerardkortney
 
Best c programs
Best c programsBest c programs
Best c programs
AbhishekSharma471920
 
Simple c-programs
Simple c-programsSimple c-programs
Simple c-programs
rashmi322
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
racha49
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
SamridhiGulati4
 
Introduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptIntroduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.ppt
BhargaviDalal4
 
C++ for beginners
C++ for beginnersC++ for beginners
C++ for beginners
Salahaddin University-Erbil
 
C code examples
C code examplesC code examples
Problem solving techniques in c language
Problem solving techniques in c languageProblem solving techniques in c language
Problem solving techniques in c language
John Bruslin
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
Samuel Igbanogu
 
Data_Structure_and_Algorithms_Lecture_1.ppt
Data_Structure_and_Algorithms_Lecture_1.pptData_Structure_and_Algorithms_Lecture_1.ppt
Data_Structure_and_Algorithms_Lecture_1.ppt
ISHANAMRITSRIVASTAVA
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy Book
Abir Hossain
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
Mard Geer
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
SourabhPal46
 
Problem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study materialProblem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study material
To Sum It Up
 

Similar to Problem solving and design (20)

Logic Development and Algorithm.
Logic Development and Algorithm.Logic Development and Algorithm.
Logic Development and Algorithm.
 
Chapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docxChapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docx
 
Problem solving (C++ Programming)
Problem solving (C++ Programming)Problem solving (C++ Programming)
Problem solving (C++ Programming)
 
Md university cmis 102 week 3 hands
Md university cmis 102 week 3 handsMd university cmis 102 week 3 hands
Md university cmis 102 week 3 hands
 
UNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.pptUNIT-2-PPTS-DAA.ppt
UNIT-2-PPTS-DAA.ppt
 
OverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docxOverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docx
 
Best c programs
Best c programsBest c programs
Best c programs
 
Simple c-programs
Simple c-programsSimple c-programs
Simple c-programs
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
Introduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptIntroduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.ppt
 
C++ for beginners
C++ for beginnersC++ for beginners
C++ for beginners
 
C code examples
C code examplesC code examples
C code examples
 
Problem solving techniques in c language
Problem solving techniques in c languageProblem solving techniques in c language
Problem solving techniques in c language
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
 
Data_Structure_and_Algorithms_Lecture_1.ppt
Data_Structure_and_Algorithms_Lecture_1.pptData_Structure_and_Algorithms_Lecture_1.ppt
Data_Structure_and_Algorithms_Lecture_1.ppt
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy Book
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
 
lec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.pptlec_4_data_structures_and_algorithm_analysis.ppt
lec_4_data_structures_and_algorithm_analysis.ppt
 
Problem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study materialProblem solving using computers - Unit 1 - Study material
Problem solving using computers - Unit 1 - Study material
 

Recently uploaded

A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
Shinana2
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
SAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloudSAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloud
maazsz111
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
Data Hops
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 

Recently uploaded (20)

A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
SAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloudSAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloud
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3FREE A4 Cyber Security Awareness  Posters-Social Engineering part 3
FREE A4 Cyber Security Awareness Posters-Social Engineering part 3
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 

Problem solving and design

  • 2. STAGES OF PROGRAM DEVELOPMENT  PROBLEM DEFINITION  ANALYSIS  DESIGN A SOLUTION USING AN ALGORITHM  WRITE A COMPUTER PROGRAM  TEST AND DEBUG THE PROGRAM  DOCUMENT THE PROGRAM Problem- Solving Phase Implementation Phase
  • 3. PROBLEM SOLVING PHASE: STEP 1: Define the problem STEP 2: Find the solution to the problem STEP 3: Evaluate alternative solutions STEP 4: Represent the most efficient solution as an algorithm STEP 5: Test the algorithm for correctness
  • 4. STAGE 1: DEFINING THE PROBLEM Stating what the problem is and what the end result should be. A problem should be decomposed into 3 key components: 1. INPUT 2. PROCESS 3. OUTPUT
  • 5. DEFINING THE PROBLEM INPUT (What is given) OUTPUT (The expected output) PROCESS (Tasks that must be performed)
  • 6. Example:  Write a program that enters a student name and date of birth and calculate the child’s age and write the name and age of the child.
  • 7. PROBLEM DEFINITION:  Required to find the age of a child  DEFINING DIAGRAM INPUT PROCESS OUTPUT 1. Student Name Calculate the child’s age 1. Student Name 2. Student DOB From the child’s DOB 2. Student Age
  • 8. Questions 1. Write a program that is required to read three (3) numbers, calculate and print their total. 2. Give three integers representing the age of three boys respectively, write a program to find their average and also determine the age of the oldest boy. 3. Write a program to enter the base and height of a triangle and find and print the area. 4. Write a program to read the temperature in degrees Celsius and convert it to degrees Celsius and Fahrenheit.
  • 9. PROBLEM DEFINITIONS: 1. Required to find the Total of three numbers. 2. Required to find the average age of 3 boys and the age of the oldest boy. 3. Required to find the Area of a triangle. 4. Required to find the Fahrenheit equivalent of a temperature in degrees Celsius.
  • 10. DEFINING DIAGRAM: QUES. 1 INPUT PROCESS OUTPUT NUM1 GET NUM1, NUM2, NUM3 TOTAL/SUM NUM2 CALCULATE TOTAL USING NUM1, NUM2,NUM3 NUM3 DISPLAY TOTAL
  • 11. QUES. 2 INPUT PROCESS OUTPUT AGE1 1. Read AGE1, AGE2, AGE3 1.AVERAGE AGE AGE2 2. CALCULATE AVERAGE AGE USING AGE1, AGE2, AGE3. 2. AGE OF OLDEST BOY AGE 3 3. FIND AGE OF OLDEST BOY FROM AGE1, AGE2, AGE3 4. DISPLAY AVERAGE, AGE OF OLDEST BOY
  • 12. QUES. 3 INPUT PROCESS OUTPUT BASE READ BASE, HEIGHT AREA OF TRIANGLE HEIGHT CALCULATE AREA USING BASE AND HEIGHT DISPLAY AREA
  • 13. QUES. 4 INPUT PROCESS OUPUT DEGREES CELCIUS READ DEGREES CELCIUS DEGREES FAHRENHEIT CALCULATE DEGREES FAHRENHEIT USING DEGREES CELCIUS DISPLAY DEGREES FAHRENHEIT
  • 14. ALGORITHMS  An algorithm is a series of steps to be followed to perform a task. An algorithm should be: 1. Precise 2. Unambiguous 3. Finite (i.e. terminate after a given number of steps) 4. Instructions must be in Logical order
  • 15. Questions 1. Identify which of the options gives the steps in correct sequence: (a) Get on the bus, get dressed for school, get off the bus at school (b) Get dressed for school, get off the bus at school, get on the bus (c) Get off the bus at school, get on the bus, get dressed for school (d) Get dressed for school, get on the bus, get off the bus at school 2. Consider the following algorithms & identify which one accurately gives the area of a square: (a) Get length and width Area = length x width (b) Get side measurement of square Area = side x side (c) Get area of square Area =Area x 2 (d) Get side measurement of square Area = side x 4
  • 16. 3. Consider the following algorithm and choose the correct step to make it complete: Purchase some ice-cream and toppings Get ice-cream scoop Use scoop to place two scoops of ice-cream on cone Cover with sprinkles Add a cherry to the top (a) Eat cake (b) Go to the cinema (c) Purchase cone (d) Enjoy the movie
  • 17. VARIABLES  A Variable is a location in memory where data of different types are stored. When you declare a variable the computer sets aside a location in memory to store data. num1 num2 sum E.g. var num1, num2, sum: integer;
  • 18.  A variable can be given a value or a variable can be set to a specific value. E.g. num1:= 1 Or the user inputs the value for num1 (1, 2, 3, 5, 90, etc.)
  • 19.  A variable can hold ONLY one value at a time. If a new value is entered, the old one is lost. e.g. 5 is currently being stored in the num1 memory location with the label, num1 (variable). If you enter a new value, say 15 for the variable num1, the value 5 is replaced by the value num1 15. 5 15
  • 20. 1)Write a program that is required to read three (3) numbers, calculate and print their total. 2)Write a program to enter girls’ heights. Calculate the average height of the girls. • Underline the variables in your program! 3)Identify all the variables in the program AreaOfSquare.
  • 21. 1. Write an algorithm to find the sum of two numbers and display the sum. 2. Write an algorithm to enter the name of an item, Cost Price of an item, the number of items purchased; calculate the Total Cost of items and display the name of the item and total cost of the items. 3. Write an algorithm to enter a student’s name, three marks; calculate the average mark. Display the student’s name and average mark.
  • 22. Program AreaOfSquare; var s, a: integer; Begin write(‘Enter length of side:’); read (s); {store length in s} a:= s*s; {calculate area; store in a} writeln; {print a blank line} writeln(‘Area of square is’, a); End.
  • 23. VARIABLE NAMES/Identifiers The variable name can: • Start with a letter or underscore • Be a combination of letters, digits and underscore • The length of the variable name cannot exceed 31 characters • No spaces are allowed in the variable names
  • 24. Exercise:  Identify the valid and invalid variable names: R _XYZ Alpha;beta Net Pay Maxamt Root1 2hottohandle
  • 25. DATA TYPES  Integer  Real (floating point)  String  Boolean (data which can be true or false)  Character (data consisting of a single character)
  • 26. Examples of data types:  Integer:- 3, -59, 0, 1987  Real:- 3.142, -5.0, 1.16  Boolean:- True or False  Character- ‘k’, ‘8’  String:- ‘Hi there’
  • 27. ALGORITHMIC STRUCTURE  Header- Algorithm’s name or title  Declaration- A brief description of algorithm and variables used.  Body- sequence of steps  Terminator- end statement
  • 28. PSEUDOCODE  An outline of a program, written in a form that can easily be converted into real programming statements.
  • 29. CONTROL STRUCTURES  SEQUENCE  SELECTION  REPETITION (LOOP)
  • 30. SEQUENTIAL STRUCTURE  INPUT STATEMENTS. For example, A. Get num1, num2 B. Read price • OUTPUT STATEMENTS. For example, A. Print Total_Cost B. Display Average • Statements with arithmetic operations: A. Sum = num1 + num2 • Statements that assign values to variables: A. Count = 0 B. Max = 20
  • 31. SELECTION STRUCTURE  IF-THEN-ELSE A. If (A>B) then Display A B. If (age>= 50) Print “Old” Else Print “Young”
  • 32. REPETITION: LOOP A. While (price <> 0) do read price total = total + price End while B. Repeat 10 times Print “I am good looking” End Repeat
  • 33. FLOWCHARTS  Algorithms can also be expressed as flowcharts. A flowchart is a pictorial representation of an algorithm.  A parallelogram- represents the input & output operation.  A rectangle- used to represent processing/assignment statements.  A diamond- represents a decision (if-then-else).  An elliptical shape- represents terminal indicators.  Directional arrows- indicate the flow of logic in the program.
  • 41. ARRAYS  An array is a special variable where we reserve a series of locations in memory to store data items of a certain data type. These related data items are of the same data type.
  • 42. DECLARING AN ARRAY  Example: var MARKS: Array[1..35] of integer; Reserved word Variable Name Group of 35 Data type MARKS is the name of the entire array. In order to access one data item the subscript is used. MARKS 1 2 3 4 5