SlideShare a Scribd company logo
1 of 44
Download to read offline
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

Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++Ankur Pandey
 
Problem solving and design
Problem solving and designProblem solving and design
Problem solving and designzahid785
 
1. over view and history of c
1. over view and history of c1. over view and history of c
1. over view and history of cHarish Kumawat
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingManoj Tyagi
 
Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)Gaditek
 
Logical and Conditional Operator In C language
Logical and Conditional Operator In C languageLogical and Conditional Operator In C language
Logical and Conditional Operator In C languageAbdul Rehman
 
Computer architecture and organization
Computer architecture and organizationComputer architecture and organization
Computer architecture and organizationTushar B Kute
 
Assembly level language
Assembly level languageAssembly level language
Assembly level languagePDFSHARE
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ LanguageWay2itech
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in CSahithi Naraparaju
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming conceptssalmankhan570
 
2.1.1 PROBLEM SOLVING & DESIGN
2.1.1 PROBLEM SOLVING & DESIGN2.1.1 PROBLEM SOLVING & DESIGN
2.1.1 PROBLEM SOLVING & DESIGNBuxoo Abdullah
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming LanguageAhmad Idrees
 
Constants and variables in c programming
Constants and variables in c programmingConstants and variables in c programming
Constants and variables in c programmingChitrank Dixit
 

What's hot (20)

Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
 
Problem solving and design
Problem solving and designProblem solving and design
Problem solving and design
 
C programming
C programmingC programming
C programming
 
1. over view and history of c
1. over view and history of c1. over view and history of c
1. over view and history of c
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)
 
Ascii
AsciiAscii
Ascii
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Logical and Conditional Operator In C language
Logical and Conditional Operator In C languageLogical and Conditional Operator In C language
Logical and Conditional Operator In C language
 
C introduction by thooyavan
C introduction by  thooyavanC introduction by  thooyavan
C introduction by thooyavan
 
CONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGECONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGE
 
Computer architecture and organization
Computer architecture and organizationComputer architecture and organization
Computer architecture and organization
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Assembly level language
Assembly level languageAssembly level language
Assembly level language
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming concepts
 
2.1.1 PROBLEM SOLVING & DESIGN
2.1.1 PROBLEM SOLVING & DESIGN2.1.1 PROBLEM SOLVING & DESIGN
2.1.1 PROBLEM SOLVING & DESIGN
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Constants and variables in c programming
Constants and variables in c programmingConstants and variables in c programming
Constants and variables in c programming
 

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 techniquesDokka 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 MethodNgurah Devara Udayana
 
Problem definition and research design workshop
Problem definition and research design workshopProblem definition and research design workshop
Problem definition and research design workshopAntónio Moniz
 
Problem Solving Techniques For Evolutionary Design
Problem Solving Techniques For Evolutionary DesignProblem Solving Techniques For Evolutionary Design
Problem Solving Techniques For Evolutionary DesignNaresh Jain
 
problem definition
problem definitionproblem definition
problem definitionnuraminramli
 
Java: Class Design Examples
Java: Class Design ExamplesJava: Class Design Examples
Java: Class Design ExamplesTareq 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 Hieuogdc
 
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 LabFelipe Lima
 
Design Thinking and Innovation
Design Thinking and InnovationDesign Thinking and Innovation
Design Thinking and InnovationTing-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_eltecsJamie 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 BasicSachinKabra
 
Critical Thinking, Problem Solving, Decision Making
Critical Thinking, Problem Solving, Decision MakingCritical Thinking, Problem Solving, Decision Making
Critical Thinking, Problem Solving, Decision Makingguestd388be
 
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 solvingBas Leurs
 
Problem definition /identification in Research
Problem definition /identification in ResearchProblem definition /identification in Research
Problem definition /identification in ResearchShameem Ali
 

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
 
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 handseyavagal
 
Research PaperIn APA style, write an original 8 to 10-page pap.docx
Research PaperIn APA style, write an original 8 to 10-page pap.docxResearch PaperIn APA style, write an original 8 to 10-page pap.docx
Research PaperIn APA style, write an original 8 to 10-page pap.docxdebishakespeare
 
Simple c-programs
Simple c-programsSimple c-programs
Simple c-programsrashmi322
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptracha49
 
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.pptBhargaviDalal4
 
Problem solving techniques in c language
Problem solving techniques in c languageProblem solving techniques in c language
Problem solving techniques in c languageJohn Bruslin
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowchartsSamuel 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.pptISHANAMRITSRIVASTAVA
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy BookAbir 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.pptMard 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.pptSourabhPal46
 
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 materialTo Sum It Up
 
RUBRIC for Multi Culture CompetencyYOU HAVE TO WRITE ABOUT EACH .docx
RUBRIC for Multi Culture CompetencyYOU HAVE TO WRITE ABOUT EACH .docxRUBRIC for Multi Culture CompetencyYOU HAVE TO WRITE ABOUT EACH .docx
RUBRIC for Multi Culture CompetencyYOU HAVE TO WRITE ABOUT EACH .docxSUBHI7
 

Similar to Problem solving and design (20)

Logic Development and Algorithm.
Logic Development and Algorithm.Logic Development and Algorithm.
Logic Development and Algorithm.
 
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
 
Research PaperIn APA style, write an original 8 to 10-page pap.docx
Research PaperIn APA style, write an original 8 to 10-page pap.docxResearch PaperIn APA style, write an original 8 to 10-page pap.docx
Research PaperIn APA style, write an original 8 to 10-page pap.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
 
RUBRIC for Multi Culture CompetencyYOU HAVE TO WRITE ABOUT EACH .docx
RUBRIC for Multi Culture CompetencyYOU HAVE TO WRITE ABOUT EACH .docxRUBRIC for Multi Culture CompetencyYOU HAVE TO WRITE ABOUT EACH .docx
RUBRIC for Multi Culture CompetencyYOU HAVE TO WRITE ABOUT EACH .docx
 

Recently uploaded

Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarPrecisely
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 

Recently uploaded (20)

Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 

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