Chapter 5 Flowcharts and programming Techniques Introduction n

  • Slides: 27
Download presentation
Chapter 5 Flowcharts and programming Techniques

Chapter 5 Flowcharts and programming Techniques

Introduction n n A flowchart is a diagram consisting of labeled geometrical symbols together

Introduction n n A flowchart is a diagram consisting of labeled geometrical symbols together with rows connecting one symbol to another A program flowchart pictures the sequence of instructions for solving a particular problem ( usually by means of a computer program).

Introduction BOUNS = 0. 03 * SALARY

Introduction BOUNS = 0. 03 * SALARY

Introduction n The sequence of instructions for solving a particular problem is called algorithm.

Introduction n The sequence of instructions for solving a particular problem is called algorithm. n Express the algorithm through a flowchart n n Easier to draw the flowchart than to write the program directly. Easier to understand than program Easy for development. Flowcharts are independent of any particular programming language

VARIABLES , DATA-NAMES, PROGRAMMING SATATEMENTS n a variable means a data item whose value

VARIABLES , DATA-NAMES, PROGRAMMING SATATEMENTS n a variable means a data item whose value may change during the execution of the program. n Examples: n Salary n Bouns n AVERAGE n Assignment Statements n Salary = 500 n Bouns = 0, 03*Salary n AVERAGE = ( T 1+T 2+T 3)/3

VARIABLES , DATA-NAMES, PROGRAMMING SATATEMENTS n HOURS = HOURS + 12 n Counter =

VARIABLES , DATA-NAMES, PROGRAMMING SATATEMENTS n HOURS = HOURS + 12 n Counter = Counter + 1

Input/Output Statements n Read NUMBER, HOURS, RATE n Write NUMBER, GROSS , NET

Input/Output Statements n Read NUMBER, HOURS, RATE n Write NUMBER, GROSS , NET

FLOWCHART SYMBLOS

FLOWCHART SYMBLOS

FLOWCHART SYMBLOS Terminal symbol Input/Output symbol

FLOWCHART SYMBLOS Terminal symbol Input/Output symbol

FLOWCHART SYMBLOS process symbol

FLOWCHART SYMBLOS process symbol

FLOWCHART SYMBLOS Decision symbol.

FLOWCHART SYMBLOS Decision symbol.

FLOWCHART SYMBLOS Example: A company plans to give a year-end 3% to each of

FLOWCHART SYMBLOS Example: A company plans to give a year-end 3% to each of its employees. However, if an employee has been working 10 or more years at the company , he is to get an additional $50.

FLOWCHART SYMBLOS

FLOWCHART SYMBLOS

FLOWCHART SYMBLOS Example: The HP company plans to give a yearend 3% bonus to

FLOWCHART SYMBLOS Example: The HP company plans to give a yearend 3% bonus to each of its employees earning $10, 000 or more per year , and a fixed $300 bonus for the other employees.

FLOWCHART SYMBLOS

FLOWCHART SYMBLOS

LOOPS AND THEIR CONTROL BY A COUNTER

LOOPS AND THEIR CONTROL BY A COUNTER

LOOPS AND THEIR CONTROL BY A COUNTER

LOOPS AND THEIR CONTROL BY A COUNTER

CONTROL OF LOOPS BY HEADER OF TRALIER RECORDS Control by a Header Record

CONTROL OF LOOPS BY HEADER OF TRALIER RECORDS Control by a Header Record

CONTROL OF LOOPS BY HEADER OF TRALIER RECORDS Control by a Trailer Record

CONTROL OF LOOPS BY HEADER OF TRALIER RECORDS Control by a Trailer Record

ACCUMULATORS

ACCUMULATORS

ACCUMULATORS Example : Suppose that a company wants to find the total salary paid

ACCUMULATORS Example : Suppose that a company wants to find the total salary paid to its employees of a company.

TWO SPECIAL ALGORITHMS: 1. The average of the salaries,

TWO SPECIAL ALGORITHMS: 1. The average of the salaries,

TWO SPECIAL ALGORITHMS: The largest salary

TWO SPECIAL ALGORITHMS: The largest salary

DO LOOPS

DO LOOPS

DO LOOPS n Example: A company has 80 employees. Draw a flowchart to find

DO LOOPS n Example: A company has 80 employees. Draw a flowchart to find the average salary and the number of employees earning above the average salary

Example

Example