Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
14 views

Flow chart and Algorithms Lecture

Uploaded by

wa1633237
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)
14 views

Flow chart and Algorithms Lecture

Uploaded by

wa1633237
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/ 25

Flow chart and Algorithms

Lecture Notes
Algorithm Vs. Flowchart

• Algorithms and flowcharts are different


mechanisms used for designing different
programs, particularly in computer
programming. An algorithm is a step-by-step
summary of the procedure, while on the other
hand, a flowchart illustrates the steps of a
program graphically.
Algorithm
• An algorithm is a procedure or set of rules
that defines how a program is to be executed.
Or we can say that it is a set of instructions for
solving a well-defined computational problem.
Flow chart
• A flowchart is a graphical representation of the
steps a program takes to process data. In this, we
can use several geometric patterns to illustrate
the numerous actions the program carries out.
• With the help of the flowchart, the designer can
efficiently segregate the various elements of the
process. Also, it facilitates the analysis by giving
step-by-step instructions on the problem.
Example 1: Find the Sum of Two
Numbers Entered
Step 1: Read the Integer A.
Step 2: Read Integer B.
Step 3: Perform the addition by using the
formula: C= A + B.
Step 4: Print the Integer C.
Flow chart
Example 2:

Determining the Largest Number Among All the


Entered Integers

Step 1: Read the Integer A.


Step 2: Read Integer B.
Step 3: If B is greater than A, then print B, else A.
Flow chart
Example 3:
Find the Fibonacci series till term ≤ 1000

Step 1: Declare the variables i, a, b, show.


Step 2: Enter the values for the variables, a=0, b=1, show=0
Step 3: Enter the terms of the Fibonacci series to be printed, i.e=, 1000.
Step 4: Print the first two terms of the series.
Step 5: Loop the following steps:
Show = a + b
a= b
b = show
Add 1 to the value of i each time.
Print Show
Flow chart
Example 4
Calculate the Sum of The First 50 Numbers

Step 1: Declare number N= 0 and sum= 0


Step 2: Determine N by N= N+1
Step 3: Calculate the sum by the formula: Sum= N + Sum.
Step 4: Add a loop between steps 2 and 3 until N= 50.
Step 5: Print Sum.
Flow chart
Example 5
Arrange the numbers X, Y, Z in descending order

Step 1: Input the value for variables X, Y, Z.


Step 2: Read the integers X, Y, Z.
Step 3: Check if x>y, x>z, y>z
Step 4: Print the possible order.
Flow chart
Example 6
Determine and Output Whether Number N is Even or
Odd

Step 1: Read number N.


Step 2: Set remainder as N modulo 2.
Step 3: If the remainder is equal to 0, then number
N is even, else number N is odd.
Step 4: Print output.
Flow chart
Example 7
Calculate the Interest of a Bank Deposit

Step 1: Read amount.


Step 2: Read years.
Step 3: Read rate.
Step 4: Calculate the interest with the formula
"Interest=Amount*Years*Rate/100.
Step 5: Print interest.
Example 8
Determine Whether a Temperature is Below or Above the
Freezing Point

Step 1: Input temperature.


Step 2: If it is less than 32, then print "below freezing
point", otherwise print "above freezing point".
Flow chart
Sum of any three numbers from user

You might also like