Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular.

Similar presentations


Presentation on theme: "Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular."— Presentation transcript:

1 Introducing block scheme programming March 17

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. 2 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

3 Flow chart basic symbols 3 Computations Input / Output Decision Start / stop Connector Flow of control

4 Adding the numbers 4 start read A, B, C S = A + B + C output S stop

5 Larger of two numbers 5 start read X, Y output X stop X > Y ? output Y stop yes no

6 Larger of three numbers 6 start read X, Y, Z stop X > Y ? stop yesno max > Z ? Output max Output z yesno Max = XMax = Y

7 7 start read N stop Count > N ? output sum no yes sum = sum + count * count sum = 0 count = 1 count = count + 1 Sum = 1 2 + 2 2 + 3 2 + … + N 2

8 8 start read N stop Count > N ? output sum no yes sum = sum + count * (count + 1) sum = 0 count = 1 count = count + 1 sum = 1 * 2 + 2 * 3 + 3 * 4 + … + N * (N +1)

9 9 start read N stop count > N ? output sum no yes prod = prod * count prod = 1 count = 1 count = count + 1 Computing factorial

10 10 start Read X, N stop count > N ? output sum no yes sum = prod * count term = term * X / count term = 1 prod = 1 count = 1 count = count + 1 Computing e x series up to N terms Use Taylor expansion to represent e x up to N terms.

11 11 start Read X, N stop term <.0001 ? output sum no yes sum = prod * count term = term * X / count term = 1 prod = 1 count = 1 count = count + 1 Computing e x series up to 4 decimal places Use Taylor expansion to represent e x up to 4 decimal places.

12 Do you it yourself Draw a block scheme for the algorithm that finds roots of quadratic equations ax 2 + bx + c = 0 12

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 13 …


Download ppt "Introducing block scheme programming March 17. Algorithm / Flow chart An algorithm or a flowchart is a step-by-step procedure for solving a particular."

Similar presentations


Ads by Google