Flow Charts And Pseudo Codes - Zahira College, Colombo

2y ago
29 Views
3 Downloads
939.73 KB
40 Pages
Last View : 15d ago
Last Download : 3m ago
Upload by : Albert Barnett
Transcription

Flow Charts AndPseudo CodesGrade 12GCE ( A/L )- ICT Teacher Training Program – 2011

An algorithm is a complete step-bystep procedure for solving a problemor accomplishing a task

Flowcharts Pseudo Codes

It is a step by step Diagrammaticrepresentation of the program Each type of task is represented by asymbol

DiagramNotationRepresentationOvalStart / End of a ProgramParallelogramInput / Output of DataRectangleProcessing OperationRhombusDecision Box

DiagramNotationRepresentationCircleConnectionFlow LinesDirection of FlowRectangleSub Process

StartInputsCalculationsOutputsStopEg :StartInput a , bSum a bOutput SumStop

Sequence Selection Iteration

SEQUENCE is a linear progressionwhere one task is performedSTARTsequentially after another.Statement 1Statement 2Statement 3STOP

StartSum 0Average 0Find the sum andaverage oftwo numbersInputNumber1InputNumber2Sum Numbe1 Number2Average Sum / 2DisplaySum, AverageStop

SELECTION - there may bealternative steps that could be takensubject to a particular conditionIF-THEN-ELSE is a decision (selection) inwhich a choice is made between two alternativecourses of action

TrueFalseCondition?Statement sequence 1Statement sequence 2

Input the length and width of aquadrilateral and state whether it is asquareStartGetLengthGetWidthIs Lengthequal toWidth ?YNDisplay“Figure is Square”Stop

Input the length and width of a quadrilateral andstate whether it is a square or a rectangle.StartGet Length, widthIs Length equalWidth ?DisplayN“Figure is Rectangle”StopYDisplay“Figure is Square”

Connectors When a flowchart is too long to fit on a pageand is to be continued on another page aconnector symbol is used A small circle is used to represent a connectorin a flowchart An alphabet or a number is written inside thecircle to identify the pairs of connectors to bejoined

AStartAdd number tovalue of totalSet value ofCounter to 0Incrementcounter by 1Set value ofTotal to 0BGet NumberIsCounter 10?YAWrite totalStopNB

ITERATION - certain steps may need tobe repeated while, or until, a certaincondition is true While For Repeat

whileStart loopfalseCondition?trueStatementsequenceEnd loop

Startcounter 0 Find the sumof 10 numberstotal 0NoCounter 10?yesDisplay totalGet NumberStoptotal total numbercounter counter 1

ForStart ForControl variable Start ValueControl variable end value?falsetrueStatement-sequenceControl variable Control variable 1End For

Display the numbers 1, 2, 3, 4, 5, ., 100Startno 1falseno 100trueDisplay nono no 1Stop

Example -7 Enter marks of 4 subjects and findthe average. If the average is lessthan 50 then display “pass” elsedisplay “fail”.

Startaverage 0Input m1, m2, m3, m4average ( m1 m2 m3 m4 ) /4IF Average 50falsetrueNDisplay“Fail”StopDisplay“Pass”

Example -8 A company gives discounts for thetotal bill paid by the customers. Ifthe Bill amount is above Rs. 5000/-, adiscount of 10 % is given. Otherwise5% is given. Input the Bill amountand calculate the discount amount.

Startdiscount 0Input Bill AmountIF Bill Amount 5000falsetrueDiscount Bill Amount * 0.10DisplayDiscountStopDiscount Bill Amount * 0.05

Example - 9 A company pays a basic salary ofRs. 8000/- to the salesmen. If asalesman does sales of Rs. 50,000/or above, he is given a 25%commission. Otherwise only 10%.Input the sales done by a salesman andcalculate his salary for the month.

StartCommission 0, Tot Salary 0Input Sales AmountIFSales Amount 50000falsetrueCommission Sales Amount * 0.25Tot Salary 8000 CommissionDisplay Tot SalaryStopCommission Sales Amount * 0.10

Pseudo codes use every day language to prepare abrief set of instructions in the order in which theywill appear in a finished program It is an abbreviated version of actual computer code(that’s why it is called Pseudocode) Once pseudocode is created, it is simple to translateinto real programming code.

Sequence– Use set of instructions one after theother Selection– Use IF THEN ELSE Repetition– Use WHILE, FOR, REPEAT UNTILL

SequenceSTARTPseudocode;statement 1Statement 1statement 2statement 3Statement 2Statement 3STOP

Example - 10 Write a pseudo code that inputs twonumbers (a and b) and calculates thesum of the numbers and output thesumINPUT aINPUT bsum a bOUTPUT sum

Compare and Select One of TwoAlternative Actions Select one path according to the condition– IF . THEN If the condition is true do the statements inside IF No operation if the condition is false– IF . THEN . ELSE If the condition is true do the statements inside IF If the condition is false do the statements inside ELSE

Pseudocode:IFTrueFalseCondition?Statement sequence 1Statement sequence 2ENDIFIF statements)ENDIF

IF condition THENsequence 1ENDIFIF condition THENsequence 1ELSEsequence 2ENDIF Example1:IF a 0 THENPrint aEND IF Example2:IF a b THENPrint aELSEPrint bEND IF

Example-11 Write a pseudo code that inputs twonumbers (a and b) and output the largestnumber.INPUT aINPUT bIF a b THENOUTPUT bELSEOUTPUT aEND IF

– WHILE ENDWHILE

WhileWhilePseudocode:WHILE Condition falseCondition?END WHILEtrueEndWhileStatementsequenceStatement- Sequence

Example - 12 Inputs 5 numbers and outputs the sum andaverage of them.count 1sum 0WHILE count 5 DoINPUT numsum sum numcount count 1END WHILEaverage sum / 5DISPLAY sum, average

Exercise Draw the flow chart and write thepseudo code for following scenario.1. Calculate the sum of odd numbersbetween 1 to 1002. Calculate the sum of first tentriangular numbers3. Find the largest number amongthree distinct integers

4. Input ten positive integer values andCalculate the average.5. Input 30 students name and ICTmark, calculate the subject averageand print “Good Class” if average isgreater than or equal 50, otherwiseprint “Bad Class”.

Pseudocode: WHILE Condition Statement-Sequence END WHILE Statement sequence true EndWhile. Example -12 Inputs 5 numbers and outputs the sum and average of them. count 1 sum 0 WHILE count 5 Do INPUT num sum sum num count count 1 END WHILE average sum / 5 DISPLAY sum, average.

Related Documents:

Pseudo-code Algorithms can be speci ed using some form of pseudo-code Good pseudo-code: I Balances clarity and detail I Abstracts the algorithm I Makes use of good mathematical notation I Is easy to read Bad pseudo-code: I Gives too many details I Is implementation or language speci c Good Pseudo-code Example Intersection

3) Auxiliary charts - change charts 4) Constant pressure charts (C.P. Charts) 5) Cross section charts, 6) Vertical time section, 7) Vertical cross section 8) Te-phi-gram 9) Radar echo charts Other charts Coverage of these charts depends upon the area for which the forecast is to

Bar Charts (Gantt Charts), Resource Histograms, and S-Curves Dr. Mohammad S. El-Mashaleh Dept. of Civil Eng. Hashemite University Construction Project Management Dr. Mohammad El-Mashaleh 2 Bar charts (Gantt charts) Like we said before, bar charts are

Pseudo Code Practice Problems: Listed below is a brief explanation of Pseudo code as well as a list of examples and solutions. Pseudo

Compute Platform SoC. The Qualcomm Pseudo Random Number Generator implements a SHA-256 Hash DRBG as defined in SP 800-90A. The hardware sub-chip cryptographic modules are specified in the following table: Component Type Version Number Qualcomm Pseudo Random Number Generator hardware 2.1.0 Qualcomm Pseudo Random Number Generator hardware 2.3.1

Oct 01, 2015 · Conformed to FSC New Codes Added No new codes. Added a definition for R&D Stage 7, Commercialization, to the manual (the related codes are already in use in FPDS). 30 new codes to capture missing services. 1 code added to match FSC list. Codes End Dated None 12 ended codes (combined with existing codes). 39 codes which have been in use in FPDS but

cheatcc.codes cheatcode.codes cheatcodes.codes cheats.codes chet.codes chets.codes chilltowin.codes

This product provides a local flow indication and automatically signals the operator or PLC if flow is too high or too low. Uses of the Flow-Alert flow meter include: bearing lubrication, case drain verification, gun drill cooling, pump flow confirmation, etc. FLOW-ALERT FLOW SWITCH 6000 PSI / 414 BARS MAX GPM LPM OIL FIGURE 1- Flow-AlERt Flow .