SlideShare una empresa de Scribd logo
1 de 44
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

Más contenido relacionado

La actualidad más candente

Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniques
Ashesh R
 
Chapter 2 Representation Of Algorithms 2
Chapter 2  Representation Of  Algorithms 2Chapter 2  Representation Of  Algorithms 2
Chapter 2 Representation Of Algorithms 2
Li-Anne Serrano
 
Call by value
Call by valueCall by value
Call by value
Dharani G
 

La actualidad más candente (20)

Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniques
 
Unit 1 program development cycle
Unit 1 program development cycleUnit 1 program development cycle
Unit 1 program development cycle
 
Types of Programming Errors
Types of Programming ErrorsTypes of Programming Errors
Types of Programming Errors
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Programming in ansi C by Balaguruswami
Programming in ansi C by BalaguruswamiProgramming in ansi C by Balaguruswami
Programming in ansi C by Balaguruswami
 
pseudocode and Flowchart
pseudocode and Flowchartpseudocode and Flowchart
pseudocode and Flowchart
 
Unit 1. Problem Solving with Computer
Unit 1. Problem Solving with Computer   Unit 1. Problem Solving with Computer
Unit 1. Problem Solving with Computer
 
2D Array
2D Array 2D Array
2D Array
 
Programming
ProgrammingProgramming
Programming
 
Programming in c
Programming in cProgramming in c
Programming in c
 
PYTHON NOTES
PYTHON NOTESPYTHON NOTES
PYTHON NOTES
 
Chapter 2 Representation Of Algorithms 2
Chapter 2  Representation Of  Algorithms 2Chapter 2  Representation Of  Algorithms 2
Chapter 2 Representation Of Algorithms 2
 
Rules for Variable Declaration
Rules for Variable DeclarationRules for Variable Declaration
Rules for Variable Declaration
 
Computer Programming- Lecture 5
Computer Programming- Lecture 5 Computer Programming- Lecture 5
Computer Programming- Lecture 5
 
Modular programming
Modular programmingModular programming
Modular programming
 
Call by value
Call by valueCall by value
Call by value
 
Algorithm Introduction
Algorithm IntroductionAlgorithm Introduction
Algorithm Introduction
 

Destacado

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
 
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
 
Critical Thinking, Problem Solving, Decision Making
Critical Thinking, Problem Solving, Decision MakingCritical Thinking, Problem Solving, Decision Making
Critical Thinking, Problem Solving, Decision Making
guestd388be
 
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
 

Destacado (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 a Problem solving and design

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
 
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
 

Similar a 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
 
Simple c-programs
Simple c-programsSimple c-programs
Simple c-programs
 
Best c programs
Best c programsBest c programs
Best 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
 

Último

Último (20)

HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

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