Docsity

Flowcharting and Programming: A Guide to Creating Executable Code, Study notes of Computer Science

Partial preview of the text

Download Flowcharting and Programming: A Guide to Creating Executable Code and more Study notes Computer Science in PDF only on Docsity!

Flow Chart and Phases of Making

an Executable Code

Drawing Flowcharts

  • (^) Flowchart is the graphic representations of the individual

steps or actions to implement a particular module

  • (^) Flowchart can be likened to the blueprint of a building
  • (^) An architect draws a blueprint before beginning

construction on a building, so the programmer draws a

flowchart before writing a program

  • (^) Flowchart is independent of any programming language.

PRE-PROGRAMMING PHASE

Symbol Function

Show the direction of data flow or logical solution. Indicate the beginning and ending of a set of actions or instructions (logical flow) of a module or program. Indicate a process, such as calculations, opening and closing files.

PRE-PROGRAMMING PHASE

Indicate input to the program and output from the program. Use for making decision. Either True or False based on certain condition. Use for doing a repetition or looping of certain steps. Connection of flowchart on the same page. Connection of flowchart from page to page.

Sale Problem

Given the unit price of a product and the quantity of the

product sold, draw a flowchart to calculate and print the

total sale.

Solution: Stepwise Analysis of the Sale Problem

  • (^) Read the unit price and the quantity
  • (^) Calculate total sale = unit price and quantity
  • (^) Print total sale

PRE-PROGRAMMING PHASE

START
READ
UNIT PRICE
READ
QUANTITY
A
A
TOTAL SALE =
UNITPRICE ´ QUANTITY
PRINT
TOTALSALE
STOP

The Decision Logic Structure

  • (^) Implements using the IF/THEN/ELSE instruction.
  • (^) Tells the computer that IF a condition is true, THEN execute a set of instructions, or ELSE execute another set of instructions
  • (^) ELSE part is optional, as there is not always a set of instructions if the conditions are false.
  • (^) Algorithm:

IF <condition(s)> THEN

<TRUE instruction(s)>

ELSE

<FALSE instruction(s)

Decision Logic Structure

Conditional Pay Calculation

• Assume your are calculating pay at an hourly

rate, and overtime pay(over 40 hours) at 1.

times the hourly rate.

– IF the hours are greater than 40, THEN the pay is

calculated for overtime, or ELSE the pay is

calculated in the usual way.

Example Decision Structure

NESTED IF/THEN/ELSE INSTRUCTIONS

Flow Chart - Selectional

Loop Logic Structure

WHILE loop