SlideShare a Scribd company logo
5
Most read
6
Most read
7
Most read
P.S:
It is always said any important presentation should start with black background. I don’t know why but we
do as it is said
Presented By: Ahmed Nobi ;
Ahmed nobi
- Android developer with one year experience
- Android Developer at Cleodev software House.
- programming instructor with three year experience in Luxor and Aswan.
- working on online course (programming school)
- former chair IEEE Aswan SB
- Ex Vice Student representative IEEE Egypt Section
contact me:
LinkedIn: www.linkedin.com/in/ahmed-nobi
Facebook: www.facebook.com/Ahmed.Nobi.Eltwins
mail: ahmed.nobi95@gmail.com
Co –instructor: Abdelrahman Ashraf
knowledge
Visual basic , c++ , fortran , html , Photoshop, Adobe premier
Skills
Problem solving , video editor .
contact me:
Facebook: www.facebook.com/abdul.rhman.3720
Brief about me
You ask now how to start to code ?!
Before coding, we should start with algorithms.
What is the algorithms?!
Algorithms
• An algorithm is a set of instructions designed to perform
a specific task
The algorithm may include instructions for how to:
• start
• accept information
• display information
• transformations
• how to select decisions
• how to repeat sub-tasks
• when to terminate
How can I write an algorithm ?
• The development of an algorithm (a plan) is a key step in solving a problem. Once we have
an algorithm, we can translate it into a computer program in some programming
language. Our algorithm development process consists of five major steps.
• Step 1: Obtain a description of the problem.
• Step 2: Analyze the problem.
• Step 3: Develop a high-level algorithm.
• Step 4: Refine the algorithm by adding more detail.
• Step 5: Review the algorithm.
A scope in details
1- Obtain a description of the problem.
This step is much more difficult than it appears. In the following discussion, the
word client refers to someone who wants to find a solution to a problem, and the
word developer refers to someone who finds a way to solve the problem.The developer must
create an algorithm that will solve the client's problem.
2- Analyze the problem.
The purpose of this step is to determine both the starting and ending points for solving the
problem
When determining the starting point, we should start by seeking answers to the following
questions:
-What data are available?
-Where is that data?
-What formulas pertain to the problem?
-What rules exist for working with the data?
-What relationships exist among the data values?
When determining the ending point, we need to describe the characteristics of a solution. In other words, how will we know when
we're done? Asking the following questions often helps to determine the ending point.
-What new facts will we have?
- what items will have changed?
-What changes will have been made to those items?
-What things will no longer exist?
3- Develop a high-level algorithm.
An algorithm is a plan for solving a problem, but plans come in several levels of detail. It's usually better to start with a high-level
algorithm that includes the major part of a solution, but leaves the details until later.
4- Refine the algorithm by adding more detail.
A high-level algorithm shows the major steps that need to be followed to solve a problem. Now we need to add details to these steps,
but how much detail should we add? Unfortunately, the answer to this question depends on the situation.
5- Review the algorithm.
The final step is to review the algorithm
Let us do an activity
1. A Jeroo starts at (0, 0) facing East with no flowers in its pouch.There is a flower
at location (3, 0).Write a program that directs the Jeroo to pick the flower and
plant it at location (3, 2). After planting the flower, the Jeroo should hop one
space East and stop.There are no other nets, flowers, or Jeroos on the island.
 Analysis of the Problem (Step 2)
1.The flower is exactly three spaces ahead of the jeroo.
2.The flower is to be planted exactly two spaces South of its current location.
3.The Jeroo is to finish facing East one space East of the planted flower.
4.There are no nets to worry about.
 High-level Algorithm (Step 3)
Let's name the Jeroo Bobby. Bobby should do the following:
Get the flower
Put the flower
Hop East
 Detailed Algorithm (Step 4)
Let's name the Jeroo Bobby. Bobby should do the following:
Get the flower
Hop 3 times
Pick the flower
Put the flower
Turn right Hop 2 times Plant a flower
Hop East
Turn left Hop once
 Review the Algorithm (Step 5)
1.The high-level algorithm partitioned the problem into three rather easy sub problems. This seems like a good
technique.
2.This algorithm solves a very specific problem because the Jeroo and the flower are in very specific locations.
3.This algorithm is actually a solution to a slightly more general problem in which the Jeroo starts anywhere,
4.and the flower is 3 spaces directly ahead of the Jeroo.
2- Write an algorithm of summing two numbers. Get the values from user and display the result
- Analyze the problem (step 2)
1- Sum two numbers
2-there are no values to sum
3- giving summation’s value
High level algorithm (step 3)
1- define the variables
2- determine the expression
3- get numerical values to sum
4- get the final value
5- display the value
Detailed algorithm(step 4)
1- Define 3 variables
2 variables to sum and one for final
result: x, y and z respectively
2- determine the expression
z = x+ y
3- get numerical values to sum
Read from user 2 numerical values
4- Get the final value
z = x+ y
5- display theValue Display z
Review the algorithm (step 5)
compensate by value in
the expression
The per. solution is an ideal which we can use in the huge problems (program) so we can
simplify to that one:
Another solution:
1. define 3 variables x, y and z.
2. Determine the expression : z = x + y
3. Read x and y
4. Carrying out the expression
5. Display z
More Simple
• Define x, y,z
• Read | input x,y
• Z= x+y
• Display z
• end
start
accept information
display information
transformations
how to select decisions
how to repeat sub-tasks
when to terminate
What is next ?
So how to take Decision in Algorithms
Per example
Z= x+y
how to select decisions
So if you need to take decision, you must use “if “
So if you need to design an algorithm that tell you the given number is
positive or negative
After we analyze the problem
Solution :
Start
Define x ;
Read x
If (x>0)
Display “positive”
Else
Display “Negative”
end
how to select decisions
So if you need to take decision, you must use “if “
Design an algorithm that determine if the given number is odd or even
After we analyze the problem
Solution :
Start
Define x ;
Read x
If (x mod 2 == 0)
Display “even”
Else
Display “odd”
end
start
accept information
display information
transformations
how to select decisions
how to repeat sub-tasks
when to terminate
What is next ?
Per examples
Positive or negative
Even or odd
Per example
Z= x+y
How to repeat ? we use
loops
how to repeat sub-tasks
So if you need to repeat, we use loops
Design an algorithm that help you to write your little brother to do his
homework.The homework is to write the “the lion” lesson 10 times
After we analyze the problem
Solution :
Start
Define I,hw ;
Read hw
For( I = 1 : 10 )
Display hw
end
……It is not the end
1. write an algorithm of multiplying two number .
2. Write an algorithm to calculate the area of circle 𝐴 = 𝜋𝑟2
.
3. Write an algorithm of program that display “hello world ” when user types a positive
number, and display “bye world ” when user types a negative number.
4. Write an algorithm to print numbers between 0 to 10
5. Write an algorithm to calculate the factorial of any given number x!.
6. Write a program that display the number of digits of number . Ex 321 , consists of 3 digits
7. Write an algorithm that calculate the sum of digits. Example 123 = 6
Let ‘s practice more with new ideas
Where we
can type our
code ?
• We edit our code on editor. IDE (integrated
development environment /compiler
• CodeBlocks
Next session, we
‘re going to edit
our first code 
Ad

Recommended

Looping statements in Java
Looping statements in Java
Jin Castor
 
Qbasic introduction
Qbasic introduction
Christian Joseph Opiana
 
Introduction to c programming language
Introduction to c programming language
sanjay joshi
 
algo
algo
Rao Khan
 
Algorithm and Flowcharts
Algorithm and Flowcharts
Dr. SURBHI SAROHA
 
Python programming : Control statements
Python programming : Control statements
Emertxe Information Technologies Pvt Ltd
 
Array Of Pointers
Array Of Pointers
Sharad Dubey
 
Modular programming
Modular programming
Mohanlal Sukhadia University (MLSU)
 
Algorithm and flowchart
Algorithm and flowchart
Rabin BK
 
Assembly Language
Assembly Language
Ibrahimcommunication Al Ani
 
Parallel processing
Parallel processing
Syed Zaid Irshad
 
While , For , Do-While Loop
While , For , Do-While Loop
Abhishek Choksi
 
Computer Organization and Assembly Language
Computer Organization and Assembly Language
fasihuddin90
 
Operating system deign and implementation
Operating system deign and implementation
sangrampatil81
 
Relational operators
Relational operators
Graphic Era Hill University,Bhimtal
 
Introduction to php
Introduction to php
Taha Malampatti
 
Functions in c language
Functions in c language
tanmaymodi4
 
Control Structures
Control Structures
Ghaffar Khan
 
Features of c
Features of c
Hitesh Kumar
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
REHAN IJAZ
 
Function C programming
Function C programming
Appili Vamsi Krishna
 
DDL And DML
DDL And DML
pnp @in
 
Loop(for, while, do while) condition Presentation
Loop(for, while, do while) condition Presentation
Badrul Alam
 
C standard library functions
C standard library functions
Vaishnavee Sharma
 
Phases of compiler
Phases of compiler
Akhil Kaushik
 
Programming Fundamentals
Programming Fundamentals
Trivuz ত্রিভুজ
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compiler
Iffat Anjum
 
Algorithms and Flowcharts
Algorithms and Flowcharts
Deva Singh
 
Algorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo code
hamza javed
 
Std 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem Solving
Nuzhat Memon
 

More Related Content

What's hot (20)

Algorithm and flowchart
Algorithm and flowchart
Rabin BK
 
Assembly Language
Assembly Language
Ibrahimcommunication Al Ani
 
Parallel processing
Parallel processing
Syed Zaid Irshad
 
While , For , Do-While Loop
While , For , Do-While Loop
Abhishek Choksi
 
Computer Organization and Assembly Language
Computer Organization and Assembly Language
fasihuddin90
 
Operating system deign and implementation
Operating system deign and implementation
sangrampatil81
 
Relational operators
Relational operators
Graphic Era Hill University,Bhimtal
 
Introduction to php
Introduction to php
Taha Malampatti
 
Functions in c language
Functions in c language
tanmaymodi4
 
Control Structures
Control Structures
Ghaffar Khan
 
Features of c
Features of c
Hitesh Kumar
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
REHAN IJAZ
 
Function C programming
Function C programming
Appili Vamsi Krishna
 
DDL And DML
DDL And DML
pnp @in
 
Loop(for, while, do while) condition Presentation
Loop(for, while, do while) condition Presentation
Badrul Alam
 
C standard library functions
C standard library functions
Vaishnavee Sharma
 
Phases of compiler
Phases of compiler
Akhil Kaushik
 
Programming Fundamentals
Programming Fundamentals
Trivuz ত্রিভুজ
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compiler
Iffat Anjum
 
Algorithms and Flowcharts
Algorithms and Flowcharts
Deva Singh
 
Algorithm and flowchart
Algorithm and flowchart
Rabin BK
 
While , For , Do-While Loop
While , For , Do-While Loop
Abhishek Choksi
 
Computer Organization and Assembly Language
Computer Organization and Assembly Language
fasihuddin90
 
Operating system deign and implementation
Operating system deign and implementation
sangrampatil81
 
Functions in c language
Functions in c language
tanmaymodi4
 
Control Structures
Control Structures
Ghaffar Khan
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
REHAN IJAZ
 
DDL And DML
DDL And DML
pnp @in
 
Loop(for, while, do while) condition Presentation
Loop(for, while, do while) condition Presentation
Badrul Alam
 
C standard library functions
C standard library functions
Vaishnavee Sharma
 
Lecture 01 introduction to compiler
Lecture 01 introduction to compiler
Iffat Anjum
 
Algorithms and Flowcharts
Algorithms and Flowcharts
Deva Singh
 

Similar to Algorithms and how to write an algorithms (20)

Algorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo code
hamza javed
 
Std 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem Solving
Nuzhat Memon
 
Pengenalan kepada pengaturcaraan berstruktur
Pengenalan kepada pengaturcaraan berstruktur
Unit Kediaman Luar Kampus
 
Challenges-and-Consideration-in-Programming-Logic-and-Design...pptx
Challenges-and-Consideration-in-Programming-Logic-and-Design...pptx
RusherGamer1
 
Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2
Traian Rebedea
 
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
HarshJha34
 
Algorithm types performance steps working
Algorithm types performance steps working
Saurabh846965
 
Chp-1 DAA (2).pptx design analysis and algoritham presentation
Chp-1 DAA (2).pptx design analysis and algoritham presentation
vaishnavbhavna17
 
Practical 01 (detailed)
Practical 01 (detailed)
Muhammadalizardari
 
Daa unit 1
Daa unit 1
jinalgoti
 
Algorithm for computational problematic sit
Algorithm for computational problematic sit
Saurabh846965
 
Lesson 3
Lesson 3
Dr. Rupinder Singh
 
Visual Problem Solving (Lecture)
Visual Problem Solving (Lecture)
Lawrence Wachs
 
Daa chapter4
Daa chapter4
B.Kirron Reddi
 
Linear programming
Linear programming
polast
 
Study Material for Problem Solving Techniques
Study Material for Problem Solving Techniques
Bobby Murugesan
 
Small Basic Calculator Apps lesson
Small Basic Calculator Apps lesson
Edujetage
 
9th Comp Ch 1 LQ.pdf
9th Comp Ch 1 LQ.pdf
Naeem Mughal
 
L- 14. 0 Algorithm_Flowchart_Example.pdf
L- 14. 0 Algorithm_Flowchart_Example.pdf
TonmoyIslam16
 
CC-112-Lec.1.ppsx
CC-112-Lec.1.ppsx
Aamir Shahzad
 
Algorithm and flowchart with pseudo code
Algorithm and flowchart with pseudo code
hamza javed
 
Std 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem Solving
Nuzhat Memon
 
Pengenalan kepada pengaturcaraan berstruktur
Pengenalan kepada pengaturcaraan berstruktur
Unit Kediaman Luar Kampus
 
Challenges-and-Consideration-in-Programming-Logic-and-Design...pptx
Challenges-and-Consideration-in-Programming-Logic-and-Design...pptx
RusherGamer1
 
Algorithm Design and Complexity - Course 1&2
Algorithm Design and Complexity - Course 1&2
Traian Rebedea
 
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
HarshJha34
 
Algorithm types performance steps working
Algorithm types performance steps working
Saurabh846965
 
Chp-1 DAA (2).pptx design analysis and algoritham presentation
Chp-1 DAA (2).pptx design analysis and algoritham presentation
vaishnavbhavna17
 
Algorithm for computational problematic sit
Algorithm for computational problematic sit
Saurabh846965
 
Visual Problem Solving (Lecture)
Visual Problem Solving (Lecture)
Lawrence Wachs
 
Linear programming
Linear programming
polast
 
Study Material for Problem Solving Techniques
Study Material for Problem Solving Techniques
Bobby Murugesan
 
Small Basic Calculator Apps lesson
Small Basic Calculator Apps lesson
Edujetage
 
9th Comp Ch 1 LQ.pdf
9th Comp Ch 1 LQ.pdf
Naeem Mughal
 
L- 14. 0 Algorithm_Flowchart_Example.pdf
L- 14. 0 Algorithm_Flowchart_Example.pdf
TonmoyIslam16
 
Ad

Recently uploaded (20)

Insurance Underwriting Software Enhancing Accuracy and Efficiency
Insurance Underwriting Software Enhancing Accuracy and Efficiency
Insurance Tech Services
 
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Intelli grow
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
Making significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
 
What is data visualization and how data visualization tool can help.pptx
What is data visualization and how data visualization tool can help.pptx
Varsha Nayak
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Safe Software
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Insurance Underwriting Software Enhancing Accuracy and Efficiency
Insurance Underwriting Software Enhancing Accuracy and Efficiency
Insurance Tech Services
 
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Smart Financial Solutions: Money Lender Software, Daily Pigmy & Personal Loan...
Intelli grow
 
Step by step guide to install Flutter and Dart
Step by step guide to install Flutter and Dart
S Pranav (Deepu)
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Advanced Token Development - Decentralized Innovation
Advanced Token Development - Decentralized Innovation
arohisinghas720
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
Making significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
 
What is data visualization and how data visualization tool can help.pptx
What is data visualization and how data visualization tool can help.pptx
Varsha Nayak
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Safe Software
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
wAIred_RabobankIgniteSession_12062025.pptx
wAIred_RabobankIgniteSession_12062025.pptx
SimonedeGijt
 
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
Milwaukee Marketo User Group June 2025 - Optimize and Enhance Efficiency - Sm...
BradBedford3
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
GDG Douglas - Google AI Agents: Your Next Intern?
GDG Douglas - Google AI Agents: Your Next Intern?
felipeceotto
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
Who will create the languages of the future?
Who will create the languages of the future?
Jordi Cabot
 
Ad

Algorithms and how to write an algorithms

  • 1. P.S: It is always said any important presentation should start with black background. I don’t know why but we do as it is said Presented By: Ahmed Nobi ;
  • 2. Ahmed nobi - Android developer with one year experience - Android Developer at Cleodev software House. - programming instructor with three year experience in Luxor and Aswan. - working on online course (programming school) - former chair IEEE Aswan SB - Ex Vice Student representative IEEE Egypt Section contact me: LinkedIn: www.linkedin.com/in/ahmed-nobi Facebook: www.facebook.com/Ahmed.Nobi.Eltwins mail: [email protected] Co –instructor: Abdelrahman Ashraf knowledge Visual basic , c++ , fortran , html , Photoshop, Adobe premier Skills Problem solving , video editor . contact me: Facebook: www.facebook.com/abdul.rhman.3720 Brief about me
  • 3. You ask now how to start to code ?! Before coding, we should start with algorithms. What is the algorithms?!
  • 4. Algorithms • An algorithm is a set of instructions designed to perform a specific task The algorithm may include instructions for how to: • start • accept information • display information • transformations • how to select decisions • how to repeat sub-tasks • when to terminate
  • 5. How can I write an algorithm ? • The development of an algorithm (a plan) is a key step in solving a problem. Once we have an algorithm, we can translate it into a computer program in some programming language. Our algorithm development process consists of five major steps. • Step 1: Obtain a description of the problem. • Step 2: Analyze the problem. • Step 3: Develop a high-level algorithm. • Step 4: Refine the algorithm by adding more detail. • Step 5: Review the algorithm.
  • 6. A scope in details 1- Obtain a description of the problem. This step is much more difficult than it appears. In the following discussion, the word client refers to someone who wants to find a solution to a problem, and the word developer refers to someone who finds a way to solve the problem.The developer must create an algorithm that will solve the client's problem. 2- Analyze the problem. The purpose of this step is to determine both the starting and ending points for solving the problem When determining the starting point, we should start by seeking answers to the following questions: -What data are available? -Where is that data? -What formulas pertain to the problem? -What rules exist for working with the data? -What relationships exist among the data values?
  • 7. When determining the ending point, we need to describe the characteristics of a solution. In other words, how will we know when we're done? Asking the following questions often helps to determine the ending point. -What new facts will we have? - what items will have changed? -What changes will have been made to those items? -What things will no longer exist? 3- Develop a high-level algorithm. An algorithm is a plan for solving a problem, but plans come in several levels of detail. It's usually better to start with a high-level algorithm that includes the major part of a solution, but leaves the details until later. 4- Refine the algorithm by adding more detail. A high-level algorithm shows the major steps that need to be followed to solve a problem. Now we need to add details to these steps, but how much detail should we add? Unfortunately, the answer to this question depends on the situation. 5- Review the algorithm. The final step is to review the algorithm
  • 8. Let us do an activity 1. A Jeroo starts at (0, 0) facing East with no flowers in its pouch.There is a flower at location (3, 0).Write a program that directs the Jeroo to pick the flower and plant it at location (3, 2). After planting the flower, the Jeroo should hop one space East and stop.There are no other nets, flowers, or Jeroos on the island.
  • 9.  Analysis of the Problem (Step 2) 1.The flower is exactly three spaces ahead of the jeroo. 2.The flower is to be planted exactly two spaces South of its current location. 3.The Jeroo is to finish facing East one space East of the planted flower. 4.There are no nets to worry about.  High-level Algorithm (Step 3) Let's name the Jeroo Bobby. Bobby should do the following: Get the flower Put the flower Hop East  Detailed Algorithm (Step 4) Let's name the Jeroo Bobby. Bobby should do the following: Get the flower Hop 3 times Pick the flower Put the flower Turn right Hop 2 times Plant a flower Hop East Turn left Hop once  Review the Algorithm (Step 5) 1.The high-level algorithm partitioned the problem into three rather easy sub problems. This seems like a good technique. 2.This algorithm solves a very specific problem because the Jeroo and the flower are in very specific locations. 3.This algorithm is actually a solution to a slightly more general problem in which the Jeroo starts anywhere, 4.and the flower is 3 spaces directly ahead of the Jeroo.
  • 10. 2- Write an algorithm of summing two numbers. Get the values from user and display the result - Analyze the problem (step 2) 1- Sum two numbers 2-there are no values to sum 3- giving summation’s value High level algorithm (step 3) 1- define the variables 2- determine the expression 3- get numerical values to sum 4- get the final value 5- display the value Detailed algorithm(step 4) 1- Define 3 variables 2 variables to sum and one for final result: x, y and z respectively 2- determine the expression z = x+ y 3- get numerical values to sum Read from user 2 numerical values 4- Get the final value z = x+ y 5- display theValue Display z Review the algorithm (step 5) compensate by value in the expression
  • 11. The per. solution is an ideal which we can use in the huge problems (program) so we can simplify to that one: Another solution: 1. define 3 variables x, y and z. 2. Determine the expression : z = x + y 3. Read x and y 4. Carrying out the expression 5. Display z More Simple • Define x, y,z • Read | input x,y • Z= x+y • Display z • end
  • 12. start accept information display information transformations how to select decisions how to repeat sub-tasks when to terminate What is next ? So how to take Decision in Algorithms Per example Z= x+y
  • 13. how to select decisions So if you need to take decision, you must use “if “ So if you need to design an algorithm that tell you the given number is positive or negative After we analyze the problem Solution : Start Define x ; Read x If (x>0) Display “positive” Else Display “Negative” end
  • 14. how to select decisions So if you need to take decision, you must use “if “ Design an algorithm that determine if the given number is odd or even After we analyze the problem Solution : Start Define x ; Read x If (x mod 2 == 0) Display “even” Else Display “odd” end
  • 15. start accept information display information transformations how to select decisions how to repeat sub-tasks when to terminate What is next ? Per examples Positive or negative Even or odd Per example Z= x+y How to repeat ? we use loops
  • 16. how to repeat sub-tasks So if you need to repeat, we use loops Design an algorithm that help you to write your little brother to do his homework.The homework is to write the “the lion” lesson 10 times After we analyze the problem Solution : Start Define I,hw ; Read hw For( I = 1 : 10 ) Display hw end
  • 17. ……It is not the end
  • 18. 1. write an algorithm of multiplying two number . 2. Write an algorithm to calculate the area of circle 𝐴 = 𝜋𝑟2 . 3. Write an algorithm of program that display “hello world ” when user types a positive number, and display “bye world ” when user types a negative number. 4. Write an algorithm to print numbers between 0 to 10 5. Write an algorithm to calculate the factorial of any given number x!. 6. Write a program that display the number of digits of number . Ex 321 , consists of 3 digits 7. Write an algorithm that calculate the sum of digits. Example 123 = 6 Let ‘s practice more with new ideas
  • 19. Where we can type our code ? • We edit our code on editor. IDE (integrated development environment /compiler • CodeBlocks
  • 20. Next session, we ‘re going to edit our first code 