Upcoming SlideShare
×

CSC1100 - Chapter12 - Flow Charts

488 views

Published on

ဖြစ်စဉ်စီးကြောင်းပြဇယားများ

Published in: Technology
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
488
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
8
0
Likes
0
Embeds 0
No embeds

No notes for slide

CSC1100 - Chapter12 - Flow Charts

1. 1. 1Chapter 12FLOWCHARTS
2. 2. 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
3. 3. 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
4. 4. 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
5. 5. 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
6. 6. 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
7. 7. 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
8. 8. 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
9. 9. 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
10. 10. 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
11. 11. 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
13. 13. 13PROGRAM STRUCTUREPROGRAM STRUCTUREPROGRAM STRUCTUREPROGRAM STRUCTURE
14. 14. 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
15. 15. 15Figure 1: Sequential Logic Structure
16. 16. 16Figure 2: Decision Logic Structure
17. 17. 17Figure 3: Loop Logic Structure
18. 18. 18Figure 4: Case Logic Structure
19. 19. 19Problem Solving with Computers (e.g.)
20. 20. 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