Presentation on theme: "C Programming Technique – Firdaus-Harun.com"— Presentation transcript:
1 C Programming Technique – Firdaus-Harun.com Pseudocode
2 Agenda Intro to Pseudocode Pseudocode vs Flowchart Technique – Write pseudocodeExamples
3 What’s Pseudocode ? Artificial and Informal language Helps programmers to plan an algorithmSimilar to everyday EnglishNot an actual programming language
4 E.g : PseudocodeRead A, B Calculate C = A*B Display C Stop
5 Technique Do not write Start in every pseudocode Parallelogram – Read / Get OR Display / PrintRectangle – Specify the actionsE.g:Calculate A = B + C OR A equals to B plus CAverage = total / countFinal price equals price of item plus sales taxDiamond – [Next »]
6 Technique (..Cont.) Diamond Selection – IF , IF / ELSE and IF / ELSE IFIF A is less than BBIG = BSMALL = AELSEBIG = ASMALL = BRepetition – WHILE / DO/WHILE / FOR [Next example]
7 Comparative Between Flowchart vs Pseudocode A graphical way of writing pseudocodeRounded rectangle – terminalParallelogram – input / outputRectangle – actionsDiamonds – decision / conditionalCircles – connector
8 E.g : Flowchart Process Output Start Terminal. Program start here Input.Enter values forA and BProcessOutputStop TerminalProgram endhere
9 Comparative Between Flowchart vs Pseudocode (..Cont.) No syntax rule – Independent from any programming languageWrite in an ordinary languageUses a structure resembling computer structureNo connector between pages
10 E.g : PseudocodeRead A, B Calculate C = A*B Display C Stop
11 E.g : PseudocodeRead A, B – Input Calculate C = A*B - Action Display C - Output Stop - Terminal
12 Example 2 (Selection) Read A, B BIG = B SMALL = A ELSE BIG = A IF A is less than BBIG = BSMALL = AELSEBIG = ASMALL = BWrite / Display BIG, SMALLStop
13 Example 2 (Selection) Read A, B - Input BIG = B - Action IF A is less than B - SelectionBIG = B - ActionSMALL = A - ActionELSE - SelectionBIG = A - ActionSMALL = B - ActionWrite / Display BIG, SMALL - OutputStop - Terminal
14 Example 3 (Repetition)Set count to zero Set total to zero Read number WHILE ( not end-of-data ) increment count by 1 total = total + number read number IF ( count > 0 ) then average = total / count Display average Stop
15 AdvantagesConverting a pseudocode to a programming language is much more easier than converting a flowchart.As compared to flowchart, it is easier to modify a pseudocode of a program logic when program modifications are necessary.
16 LimitationsIn the cases of pseudocode, a graphic representation of program logic is not available.There are no standard rules to follow for using a pseudocode.Different programmers use their own style of writing pseudocode; and hence,Communication problem occurs due to lack of standardization.
17 Class Tutorial *Using previous Flowchart tutorial. Write a pseudocode to calculate Area and Perimeter of a trapezoid.Write an algorithm to set a Median for given number : ………………………..
Your consent to our cookies if you continue to use this website.