• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
CSC1100 - Chapter12 - Flow Charts

CSC1100 - Chapter12 - Flow Charts







Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    CSC1100 - Chapter12 - Flow Charts CSC1100 - Chapter12 - Flow Charts Presentation Transcript

    • 1Chapter 12FLOWCHARTS
    • 2Problem SolvingCan be solved in a series of actionsProblem solving steps:1. Identify the problem2. Understand the problem3. Identify alternatives (solutions)4. Select the best solution4. Select the best solution5. Prepare a list of steps (instruction)6. Evaluate the solution
    • 3SOLUTIONSAlgorithmic Heuristicthe best alternativesolution reached bycompleting actions insteps – algorithmcannot be reached throughdirect set of steps– require reasoning built onknowledge & experience– a process of trial & error
    • 4Problem Solving with ComputersSolutioninstructions listed duringstep 5 of problem solving– must be followed toproduce best resultsResultThe outcomeor completedcomputer-assistedanswerProgramComputers deal with algorithmic solutions & heuristicsolutions (artificial intelligence)Programset of instructions thatmake up the solutionafter they have beencoded into a particularcomputer language
    • 5Constants & VariablesConstantAn alphabetical and/ornumerical value thatnever changes during theprocessing of all theinstructions in a solutionVariable(identifiers) Maychange duringprocessingGiven a name & a locationin memory- Referred to by given name
    • 6Drawing the FlowchartsConnect blocks by exiting from oneand entering anotherThe arrowhead is necessaryFLOWLINESFLOWLINESIndicate the start & end of aprogramStartStart has one flowline exitingExitExit has one flowline enteringStartStartExitExit
    • 7Drawing the Flowcharts (cont.)For calculations,…Has one flowline entering and oneexitingPROCESSINGPROCESSINGIndicates input to and output fromthe computer memoryHas one entrance & one exitI/OI/O
    • 8Drawing the Flowcharts (cont.)Indicates a decisionHas one entrance & two exitsOne exit is the action when theresultant is TRUE & other exit is theaction when the resultant is FALSEDecisionDecisioni < 10T FDisplay “i isless than 10”ExitExit
    • 9Problem Solving with ComputersProblem: Display Area of a CircleSteps to solve the problem:1. Declare & Initialize PI value2. Declare & Initialize Radius value3. Declare & Initialize Area value4. Calculate Area5. Display the value of Area
    • 10Drawing the Flowchart & Writing AlgorithmDisplay Area of a CircleStartDeclare & initializePI, Radius and AreaAlgorithm1. Constant PI = 3.1422. Variable Radius = 10ExitCalculate AreaDisplay Area2. Variable Radius = 103. Variable Area = 0.04. Area = PI x Radius x Radius5. Display Area
    • 11Writing the AlgorithmsDisplay Area of a CircleAlgorithm1. Constant PI = 3.1422. Variable Radius = 103. Variable Area = 0.04. Area = PI x Radius x Radius5. Display Area…PI = 3.142……5. Display Area …Radius = 40…Area = 0.0…314.2314.2Output at monitor screen
    • 12Drawing the Flowchart & Writing AlgorithmDisplay Area of a CircleStartDeclare & initializePI, Radius and AreaAlgorithm1. Declare Constant PI=3.142,2. Variable Radius=0Get RadiusExitCalculate AreaDisplay Area2. Variable Radius=03. Variable Area=0.04. Get Radius5. Area = PI x Radius x Radius6. Display Area
    • 14Program StructureUse FOUR logic structures to ensure the solution flowssmoothly from one instruction to the next, rather than jumpingbetween points1. Sequential structure executes instructions one after another in asequence2. Decision structure branches to execute one of the possible sets ofinstructionsinstructions3. Loop structure executes a set of instructions many times4. Case structure executes a set of instructions out of several setsEfficient by providing smooth transformation of data intoinformation besides eliminating the rewriting of identicalprocessesTechniques to improve program readability: the 4 logicstructure, proper naming of variables, internal documentationand proper indentation
    • 15Figure 1: Sequential Logic Structure
    • 16Figure 2: Decision Logic Structure
    • 17Figure 3: Loop Logic Structure
    • 18Figure 4: Case Logic Structure
    • 19Problem Solving with Computers (e.g.)
    • 20Draw a flowchart to calculate bonus for an employeebased on the following table:Annual Hours Worked BonusLess than 2000 hours RM 500Less than 2000 hours RM 500Between 2000 and 2499 hours RM 500 + 1 month salaryMore than 2500 hours RM500 + 2 months salary