SlideShare a Scribd company logo
1 of 25
Problem Solving Skills
2
3
1st Basic Operation : Input
• When a computer is required to take an input from a particular source,
whether it is a terminal, a disk or any other device, the verbs Read and
Get are used.
• Example :
• You are writing an essay in MS word
• Computer reads/gets 2 values to add them up
4
2nd Basic Operation : Output
• When a computer is required to provide output to a device, the verbs
Print, Write, Output, or Display are used in pseudo code.
• Usually an output Prompt instruction is required before an input Get
instruction.
• Example :
• You are viewing and printing your essay
• Computer displays / writes the added result of 2 values
5
3rd Basic Operation : Processing
• Arithmetic Operations:
• Mathematical calculation, Formula, and for these, a programmer uses either
actual mathematical symbols or the words for those symbols.
• Comparison or Logical Operations:
• A computer can compare two variables and select one or two alternate
actions
• Example:
X = 5,Y = 7 X >Y OR X <Y
Z = X +Y
Z = 5 + 7
Z = 12 6
4th Basic Operation : Storage
• An information is stored in some location in memory called Variable.
• 3 situations when need to store a value to a variable or memory location:
• To give data an initial value in pseudo code, the verbs Initialize or Set are used
• To assign a value as a result of some processing the symbols '=' or ‘' are
written
• To keep a variable for later use, the verbs Save or Store are used
• Example:
• You are downloading a song in your laptop
• Z = X +Y or Z  X +Y
7
Problem to Solve
What steps would you propose to solve the following problem?
Your hair are dirty/greasy and want to clean up
8
Problem to Solve
• Problem:
Hair are dirty
• Solution:
Wash the hair
• How:
Wash the hair Algorithm
Algorithm
• Turn on water tab
• Wet you hair
• Apply shampoo
• Wash
• Rinse hair
• Dry off
9
Steps in Problem Solving (in computer
programming)
• Computer programming can be divided into two phases:
• Problem solving phase
• Make an ordered sequence of steps that solves a problem
• These sequence of steps is called an algorithm
• Implementation phase
• Implement using a programming language
10
Steps in Problem Solving
• First produce a general algorithm (one can use pseudocode)
• Refine the algorithm successively to get step by step detailed
algorithm that is very close to a computer language.
• Pseudocode is an informal language that helps programmers
develop algorithms. Pseudocode is very similar to everyday
English.
11
Pseudocode & Algorithm
•Example 1:Write an algorithm to determine a student’s
final grade and indicate whether it is passing or failing.The
final grade is calculated as the average of four marks.
12
Pseudocode
Pseudocode:
• Input a set of 4 marks
• Calculate their average by summing and dividing by 4
• if average is below 50
Print “FAIL”
else
Print “PASS”
13
Algorithm
• Detailed Algorithm
• Step 1: Input M1,M2,M3,M4
Step 2: GRADE  (M1+M2+M3+M4)/4
Step 3: if (GRADE < 50) then
Print “FAIL”
else
Print “PASS”
endif
14
Characteristics of Algorithm
• Definite and having Input and Output
• Well-ordered
• The steps are in a clear order
• Unambiguous
• The operations described are understood by a computing
agent without further simplification.
• Effectively Computable
• The computing agent can actually carry out the operation
15
Rules of Algorithm
• For Input:
Use keyword “Input” or “Get”
followed by a list of variables
separated by a single comma.
Example
Input a
Input a , b
Get a
Get a,b
• For Output:
Use keyword “Output”,
“Display” or “Print” followed by
a variable name or text.
Enclose “text/message” in
inverted commas. Do not
enclose variable name in
inverted commas.
Example
Output “Enter a number”
Display “Your number is ”
num
16
Rules of Algorithm
• Storage/ Assignment
Use the keyword “Set” in combination with “=” or “:=” OR use
keyword “=”, “:=” or “<-”
Example
Set X=8
X=8
Set X:=8
X:= 8
X<- 8
17
Addition ofTwo Numbers
• Input: number1 and number2
• Output: Sum of number1 and number2
• Steps:
1. Start
2.Input number1 , number2
3. Sum = number1 + number2
4.Display Sum
5.End
18
Flow Chart
19
Pseudo code & Flowchart
• There are two commonly used tools to help to build logic (algorithm).
• Pseudo code is an artificial and informal language that helps programmers
develop algorithms.
• Pseudo code may be an informal English, combinations of computer
languages and spoken language.Whatever works for you.
• A Flowchart is another algorithm but graphical that shows logic solution.
• Emphasizes individual steps and their interconnections.
• A flowchart must have a start and stop.
• A step in a flowchart must connect i.e.You can’t leave a step “hanging”
with no connection. e.g. control flows from one action to the next
20
What is flow chart?
• The flowchart is one of the most basic methods of representing
algorithms. It is useful as a precise method of explanation in
some circumstances.
• A flowchart is a diagrammaticpictorial representation of the
operations involved in a data processing system.
21
Flow chart Symbols
• Start/End
• Used at the beginning and end of each flowchart.
• Input / Output
• Shows when information/data comes into a program or is
printed out.
• Process
• Used to show calculations, storing of data in variables, and
other “processes” that take place within a program.
22
Flow chart Symbols
• Decision
oUsed to show that the program must decide whether
something (usually a comparison between numbers) is true or
false.YES and NO (orT/F) branches are usually shown.
• Connector
oUsed to show that flowchart continues on another page.
• Flow Direction
oShow you how you have to move
23
X>7? Y
N
Example
Algorithm
• Step 1: Input W,L
• Step 2: A  L x W
• Step 3: Print A
START
Input
W, L
A  L x W
STOP
Output
W, L
24
Example
Input M1,M2,M3,M4
GRADE  (M1+M2+M3+M4)/4
if (GRADE <50) then
Print “FAIL”
else
Print “PASS”
endif
START
Input
M1,M2,M3,M4
GRADE(M1+M2+M3+M4)/4
IS
GRADE<50
STOP
Y
N
Print “PASS” Print “FAIL”
25

More Related Content

Similar to Lec-ProblemSolving.pptx

Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)praveena p
 
Introduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- PythonIntroduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- PythonPriyankaC44
 
AlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfAlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfSusieMaestre1
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptxTadiwaMawere
 
Cse115 lecture03problemsolving
Cse115 lecture03problemsolvingCse115 lecture03problemsolving
Cse115 lecture03problemsolvingMd. Ashikur Rahman
 
learn computer science.ppt
learn computer science.pptlearn computer science.ppt
learn computer science.pptfaithola1
 
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.pptBCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.pptKirti Verma
 
L1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfL1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfMMRF2
 
Algorithm defination, design & Implementation
Algorithm defination, design & ImplementationAlgorithm defination, design & Implementation
Algorithm defination, design & ImplementationBilal Maqbool ツ
 
Concept of Algorithm.pptx
Concept of Algorithm.pptxConcept of Algorithm.pptx
Concept of Algorithm.pptxElProfesor14
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sitSaurabh846965
 
02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptxarifaqazi2
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowchartsmoazwinner
 
Algorithm week2(technovation)
Algorithm week2(technovation)Algorithm week2(technovation)
Algorithm week2(technovation)than sare
 
Programming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptxProgramming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptxTeddyDaka
 
Algorithm & Flowchart.pdf
Algorithm & Flowchart.pdfAlgorithm & Flowchart.pdf
Algorithm & Flowchart.pdfVpmv
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptReshuReshma8
 

Similar to Lec-ProblemSolving.pptx (20)

PROBLEM SOLVING.pptx
PROBLEM SOLVING.pptxPROBLEM SOLVING.pptx
PROBLEM SOLVING.pptx
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)
 
Introduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- PythonIntroduction to Problem Solving Techniques- Python
Introduction to Problem Solving Techniques- Python
 
AlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfAlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdf
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptx
 
Cse115 lecture03problemsolving
Cse115 lecture03problemsolvingCse115 lecture03problemsolving
Cse115 lecture03problemsolving
 
Lecture1
Lecture1Lecture1
Lecture1
 
learn computer science.ppt
learn computer science.pptlearn computer science.ppt
learn computer science.ppt
 
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.pptBCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
 
L1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdfL1. Basic Programming Concepts.pdf
L1. Basic Programming Concepts.pdf
 
Algorithm defination, design & Implementation
Algorithm defination, design & ImplementationAlgorithm defination, design & Implementation
Algorithm defination, design & Implementation
 
Concept of Algorithm.pptx
Concept of Algorithm.pptxConcept of Algorithm.pptx
Concept of Algorithm.pptx
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sit
 
02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowcharts
 
Algorithm week2(technovation)
Algorithm week2(technovation)Algorithm week2(technovation)
Algorithm week2(technovation)
 
C++ good tutorial
C++ good tutorialC++ good tutorial
C++ good tutorial
 
Programming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptxProgramming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptx
 
Algorithm & Flowchart.pdf
Algorithm & Flowchart.pdfAlgorithm & Flowchart.pdf
Algorithm & Flowchart.pdf
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
 

Recently uploaded

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 

Recently uploaded (20)

ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 

Lec-ProblemSolving.pptx

  • 2. 2
  • 3. 3
  • 4. 1st Basic Operation : Input • When a computer is required to take an input from a particular source, whether it is a terminal, a disk or any other device, the verbs Read and Get are used. • Example : • You are writing an essay in MS word • Computer reads/gets 2 values to add them up 4
  • 5. 2nd Basic Operation : Output • When a computer is required to provide output to a device, the verbs Print, Write, Output, or Display are used in pseudo code. • Usually an output Prompt instruction is required before an input Get instruction. • Example : • You are viewing and printing your essay • Computer displays / writes the added result of 2 values 5
  • 6. 3rd Basic Operation : Processing • Arithmetic Operations: • Mathematical calculation, Formula, and for these, a programmer uses either actual mathematical symbols or the words for those symbols. • Comparison or Logical Operations: • A computer can compare two variables and select one or two alternate actions • Example: X = 5,Y = 7 X >Y OR X <Y Z = X +Y Z = 5 + 7 Z = 12 6
  • 7. 4th Basic Operation : Storage • An information is stored in some location in memory called Variable. • 3 situations when need to store a value to a variable or memory location: • To give data an initial value in pseudo code, the verbs Initialize or Set are used • To assign a value as a result of some processing the symbols '=' or ‘' are written • To keep a variable for later use, the verbs Save or Store are used • Example: • You are downloading a song in your laptop • Z = X +Y or Z  X +Y 7
  • 8. Problem to Solve What steps would you propose to solve the following problem? Your hair are dirty/greasy and want to clean up 8
  • 9. Problem to Solve • Problem: Hair are dirty • Solution: Wash the hair • How: Wash the hair Algorithm Algorithm • Turn on water tab • Wet you hair • Apply shampoo • Wash • Rinse hair • Dry off 9
  • 10. Steps in Problem Solving (in computer programming) • Computer programming can be divided into two phases: • Problem solving phase • Make an ordered sequence of steps that solves a problem • These sequence of steps is called an algorithm • Implementation phase • Implement using a programming language 10
  • 11. Steps in Problem Solving • First produce a general algorithm (one can use pseudocode) • Refine the algorithm successively to get step by step detailed algorithm that is very close to a computer language. • Pseudocode is an informal language that helps programmers develop algorithms. Pseudocode is very similar to everyday English. 11
  • 12. Pseudocode & Algorithm •Example 1:Write an algorithm to determine a student’s final grade and indicate whether it is passing or failing.The final grade is calculated as the average of four marks. 12
  • 13. Pseudocode Pseudocode: • Input a set of 4 marks • Calculate their average by summing and dividing by 4 • if average is below 50 Print “FAIL” else Print “PASS” 13
  • 14. Algorithm • Detailed Algorithm • Step 1: Input M1,M2,M3,M4 Step 2: GRADE  (M1+M2+M3+M4)/4 Step 3: if (GRADE < 50) then Print “FAIL” else Print “PASS” endif 14
  • 15. Characteristics of Algorithm • Definite and having Input and Output • Well-ordered • The steps are in a clear order • Unambiguous • The operations described are understood by a computing agent without further simplification. • Effectively Computable • The computing agent can actually carry out the operation 15
  • 16. Rules of Algorithm • For Input: Use keyword “Input” or “Get” followed by a list of variables separated by a single comma. Example Input a Input a , b Get a Get a,b • For Output: Use keyword “Output”, “Display” or “Print” followed by a variable name or text. Enclose “text/message” in inverted commas. Do not enclose variable name in inverted commas. Example Output “Enter a number” Display “Your number is ” num 16
  • 17. Rules of Algorithm • Storage/ Assignment Use the keyword “Set” in combination with “=” or “:=” OR use keyword “=”, “:=” or “<-” Example Set X=8 X=8 Set X:=8 X:= 8 X<- 8 17
  • 18. Addition ofTwo Numbers • Input: number1 and number2 • Output: Sum of number1 and number2 • Steps: 1. Start 2.Input number1 , number2 3. Sum = number1 + number2 4.Display Sum 5.End 18
  • 20. Pseudo code & Flowchart • There are two commonly used tools to help to build logic (algorithm). • Pseudo code is an artificial and informal language that helps programmers develop algorithms. • Pseudo code may be an informal English, combinations of computer languages and spoken language.Whatever works for you. • A Flowchart is another algorithm but graphical that shows logic solution. • Emphasizes individual steps and their interconnections. • A flowchart must have a start and stop. • A step in a flowchart must connect i.e.You can’t leave a step “hanging” with no connection. e.g. control flows from one action to the next 20
  • 21. What is flow chart? • The flowchart is one of the most basic methods of representing algorithms. It is useful as a precise method of explanation in some circumstances. • A flowchart is a diagrammaticpictorial representation of the operations involved in a data processing system. 21
  • 22. Flow chart Symbols • Start/End • Used at the beginning and end of each flowchart. • Input / Output • Shows when information/data comes into a program or is printed out. • Process • Used to show calculations, storing of data in variables, and other “processes” that take place within a program. 22
  • 23. Flow chart Symbols • Decision oUsed to show that the program must decide whether something (usually a comparison between numbers) is true or false.YES and NO (orT/F) branches are usually shown. • Connector oUsed to show that flowchart continues on another page. • Flow Direction oShow you how you have to move 23 X>7? Y N
  • 24. Example Algorithm • Step 1: Input W,L • Step 2: A  L x W • Step 3: Print A START Input W, L A  L x W STOP Output W, L 24
  • 25. Example Input M1,M2,M3,M4 GRADE  (M1+M2+M3+M4)/4 if (GRADE <50) then Print “FAIL” else Print “PASS” endif START Input M1,M2,M3,M4 GRADE(M1+M2+M3+M4)/4 IS GRADE<50 STOP Y N Print “PASS” Print “FAIL” 25