Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is...
Transcript of Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is...
![Page 1: Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.](https://reader036.fdocuments.us/reader036/viewer/2022083011/5697bfe21a28abf838cb46f9/html5/thumbnails/1.jpg)
Introducing block scheme programming
March 17
![Page 2: Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.](https://reader036.fdocuments.us/reader036/viewer/2022083011/5697bfe21a28abf838cb46f9/html5/thumbnails/2.jpg)
2
Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for
solving a particular problem, independently of the programming language.
A general plan for solving problems consist of Write the specification of the problem to be solved i.e. inputs,
outputs Draw flowchart or write algorithm Convert flowchart (algorithm) into program code Compile the program into object code Execute the program
![Page 3: Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.](https://reader036.fdocuments.us/reader036/viewer/2022083011/5697bfe21a28abf838cb46f9/html5/thumbnails/3.jpg)
3
Flow chart basic symbols
Computations
Input / Output
Decision
Start / stop
Connector
Flow of control
![Page 4: Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.](https://reader036.fdocuments.us/reader036/viewer/2022083011/5697bfe21a28abf838cb46f9/html5/thumbnails/4.jpg)
4
Adding the numbers
start
read A, B, C
S = A + B + C
output S
stop
![Page 5: Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.](https://reader036.fdocuments.us/reader036/viewer/2022083011/5697bfe21a28abf838cb46f9/html5/thumbnails/5.jpg)
5
Larger of two numbers
start
read X, Y
output X
stop
X > Y ?
output Y
stop
yes no
![Page 6: Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.](https://reader036.fdocuments.us/reader036/viewer/2022083011/5697bfe21a28abf838cb46f9/html5/thumbnails/6.jpg)
6
Larger of three numbers
start
read X, Y, Z
stop
X > Y ?
stop
yes no
max > Z ?
Output max Output z
yes no
Max = X Max = Y
![Page 7: Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.](https://reader036.fdocuments.us/reader036/viewer/2022083011/5697bfe21a28abf838cb46f9/html5/thumbnails/7.jpg)
7
start
read N
stop
Count > N ?
output sum
no yes
sum = sum + count * count
sum = 0count = 1
count = count + 1
Sum = 12 + 22 + 32 + … + N2
![Page 8: Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.](https://reader036.fdocuments.us/reader036/viewer/2022083011/5697bfe21a28abf838cb46f9/html5/thumbnails/8.jpg)
8
start
read N
stop
Count > N ?
output sum
no yes
sum = sum + count * (count + 1)
sum = 0count = 1
count = count + 1
sum = 1 * 2 + 2 * 3 + 3 * 4 + … + N* (N +1)
![Page 9: Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.](https://reader036.fdocuments.us/reader036/viewer/2022083011/5697bfe21a28abf838cb46f9/html5/thumbnails/9.jpg)
9
start
read N
stop
count > N ?
output sum
no yes
prod = prod * count
prod = 1count = 1
count = count + 1
Computing factorial
![Page 10: Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.](https://reader036.fdocuments.us/reader036/viewer/2022083011/5697bfe21a28abf838cb46f9/html5/thumbnails/10.jpg)
10
start
Read X, N
stop
count > N ?
output sum
noyes
sum = prod * countterm = term * X / count
term = 1prod = 1count = 1
count = count + 1
Computing ex series up to N terms
Use Taylor expansion to represent ex up to N terms.
![Page 11: Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.](https://reader036.fdocuments.us/reader036/viewer/2022083011/5697bfe21a28abf838cb46f9/html5/thumbnails/11.jpg)
11
start
Read X, N
stop
term < .0001 ?
output sum
noyes
sum = prod * countterm = term * X / count
term = 1prod = 1count = 1
count = count + 1
Computing ex series up to 4 decimal places
Use Taylor expansion to represent ex up to 4 decimal places.
![Page 12: Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.](https://reader036.fdocuments.us/reader036/viewer/2022083011/5697bfe21a28abf838cb46f9/html5/thumbnails/12.jpg)
12
Do you it yourself Draw a block scheme for the algorithm that finds roots of
quadratic equations ax2 + bx + c = 0
![Page 13: Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.](https://reader036.fdocuments.us/reader036/viewer/2022083011/5697bfe21a28abf838cb46f9/html5/thumbnails/13.jpg)
13
Homework Draw a flowchart for the following algorithms
1. Find whether a number is prime or not.2. Find sin(x), using the following series
Hint: see problem on slides 10 and 11
…