Is A Combination Of Natural Language And Programming Language

3.3 Pseudocode and Flowcharts

Good, logical programming is developedthrough good pre-code planning and organization. This is assistedby the use of pseudocode and program flowcharts. Flowcharts are written withprogram flow from the top of a page to the bottom. Each command isplaced in a box of the appropriate shape, and arrows are used to directprogram flow. The following shapes are often used in flowcharts: Pseudocode is a method of describingcomputer algorithms using a combination of natural language and programminglanguage. It is essentially an intermittent step towards the developmentof the actual code. It allows the programmer to formulate their thoughtson the organization and sequence of a computer algorithm without the needfor actually following the exact coding syntax. Although pseudocodeis frequently used there are no set of rules for its exact implementation.In general, here are some rules that are frequently followed when writingpseudocode:The usual Fortran symobols are used for arithmetic operations(+, -, *, / , **).Symbolic names are used to indicate the quantities beingprocessed.Certain Fortran keywords can be used, such as PRINT, WRITE,READ, etc.Indentation should be used to indicate branches and loopsof instruction.Here is an example problem, including a flowchart,pseudocode, and the final Fortran 90 program. This problem and solutionare from Nyhoff, pg 206:For a given value, Limit, what is the smallestpositive integer Number for which the sum Sum = 1 + 2 + … + Numberis greater than Limit. What is the valuefor this Sum?Pseudocode: Input: An integerLimit Ouput: Two integers: Numberand Sum1. Enter Limit2.

You are watching: Is a combination of natural language and programming language

See more: This Arch-Like Structure Extends Into Long Open Spaces To Form A Tunnel.

See more: Which Of The Following Is One Of The Most Densely Populated Regions Of Central Asia?

Set Number = 0.3. Set Sum = 0.4. Repeat the following: a. If Sum > Limit,terminate the repitition, otherwise. b. Increment Number byone. c. Add Number to Sumandset equal to Sum.5. Print Number and Sum.Flowchart:Fortran 90 code: PROGRAM Summation ! Program to find the smallestpositive integer Number ! For which Sum = 1 + 2 + …+ Number ! is greater than a user inputvalue Limit. IMPLICIT NONE ! Declare variable names andtypes INTEGER :: Number, Sum, Limit ! Initialize Sum and Number Number = 0 Sum = 0 ! Ask the user to input Limit PRINT *, “Enter the value for whichthe sum is to exceed:” READ *, Limit ! Create loop that repeats untilthe smallest value for Number is found. DO IF (Sum >Limit) EXIT ! Terminate repetition once Numberis found ! otherwiseincrement number by one Number = Number+ 1 Sum = Sum+ 1 END DO ! Print the results PRINT *, “1 + … + “, Number, “=”,Sum, “>”, Limit END PROGRAM

« previous next»


Leave a comment

Your email address will not be published. Required fields are marked *