0% found this document useful (0 votes)
61 views18 pages

Week1 L2 Flowcharts

Uploaded by

rabexa4689
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views18 pages

Week1 L2 Flowcharts

Uploaded by

rabexa4689
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Academic year:2022-2023

Semester Number:2

Programming Language

Dr: Yasser Abdelhamid


Algorithm
• A sequence of instructions is called an Algorithm
• step by step problem-solving process.
• An algorithm can be viewed as a sequence of computational steps that
transform the input into the output.

• There are two commonly used tools to help to document program


logic (the algorithm).
– Flowcharts
– Pseudocode.
Flowchart
• Steps of algorithm shown in certain shapes, the flow of data
between steps is indicated by arrows
Example
• Draw flowchart to calculate area of square
Example
Draw a flowchart to calculate area of circle
Example
• Draw flow chart to calculate Average of three numbers.
Flowchart
• Draw a flowchart to read a radius of sphere then calculate its
volume and surface area
Example
• Draw a flowchart to take your birth year and print your age

Copyright © 2014 Pearson Education, Inc.


Flowchart
• Decision

Relational operators
Example
Draw a flowchart that takes a number from the
user and if the entered number is positive start

subtract 5 from it. if it is negative add 5 to it


then print the result in either cases. Read num

No Yes
Is num>0

num=num+5 num=num-5

Print num

end
Example
• Draw flowchart to read 2 integer numbers and print the value of
the bigger followed by the smaller.
Example
• Draw a flowchart to read integer number and determine
whether it is odd or even.
Example

• Draw a flowchart to calculate the maximum value of three numbers.


loops
• Loops are constructions, that allow us to execute one or several
actions multiple times.
• They consists of two major parts: a condition and a body.
• The body contains the actions that we want to repeat.
• Each execution of the body block is called iteration.
• The condition decides whether the iterations will continue or not.

Copyright © 2014 Pearson Education, Inc.


Example
• Draw a flowchart to print numbers from 1 to n and their
squares.
Example
• Draw flow chart to add the numbers
from 1 to 10.

Can we rewrite this flowchart?


Example
• Draw flow chart to calculate factorial of n!

Copyright © 2014 Pearson Education, Inc.

You might also like