Pseudocode is a detailed description of an algorithm or program expressed in plain language rather than a programming language. It allows programmers to design programs at a high level before writing code. The document provides examples of pseudocode for control structures like conditionals and loops, and calculating sales tax and weekly wages. It also defines flowcharts as diagrams that show the sequence of operations to solve a problem and lists common flowchart symbols like rectangles, diamonds, and circles. Guidelines are given for drawing flowcharts and examples are provided of flowcharts to find the largest of three numbers and sum the first 50 natural numbers.
In this document
Powered by AI
Overview of pseudocode as a readable algorithm description and its role in programming.
Examples of control structures using pseudocode: voting age and repetition for displaying a message.
Pseudocode for computing final price including sales tax with clear input and output operations.
Example on calculating gross pay including conditional logic for overtime pay.
Definition and importance of flowcharts in illustrating problem-solving processes for programming.
Introduction to basic symbols used in flowcharts like rounded boxes, rectangles, diamonds, and circles.
Standard symbols and guidelines for creating effective flowcharts, covering start, end, decisions, and more.
Task to draw a flowchart to determine the largest of three provided numbers.
Task to create a flowchart for calculating the sum of the first 50 natural numbers.
Pseudocode (pronounced SOO-doh-kohd)is adetailed yet readable description of what a computer program or algorithm must do, expressed in a formally-styled natural language rather than in a programming language. Pseudocode is sometimes used as a detailed step in the process of developing a program. It allows designers or lead programmers to express the design in great detail and provides programmers a detailed template for the next step of writing code in a specific programming language.
3.
Sample 1Election ControlStructuresIf age > 17 Display a message indicating you can vote.Else Display a message indicating you can't vote.End
4.
Sample 2Iteration (Repetition)Control Structurescount assigned zeroWhile count < 5 Display "I love computers!" Increment countEnd while
5.
Sample 3Pseudo-code thetask of computing the final price of an item after figuring in sales tax. Note the three types of instructions: input (get), process/calculate (=) and output (display)Note that the operations are numbered and each operation is unambiguous and effectively computable. We also extract and list all variables used in our pseudo-code. This will be useful when translating pseudo-code into a programming language
6.
Computing Sales Tax1. get price ofitem2. get sales tax rate3. sales tax = price of time times sales tax rate4 final prince = price of item plus sales tax5. display final price6. end Variables: price of item, sales tax rate, sales tax, final price
7.
Sample 4Computing WeeklyWagesGross pay depends on the pay rate and the number of hours worked per week. However, if you work more than 40 hours, you get paid time-and-a-half for all hours worked over 40. Pseudo-code the task of computing gross pay given pay rate and hours worked.
8.
Code1. get hours worked2. get pay rate3. if hoursworked ≤ 40 then 3.1 gross pay = pay rate times hours worked4. else 4.1 gross pay = pay rate times 40 plus 1.5 times pay rate times (hours worked minus 40)5. display gross pay6. halt variables: hours worked, ray rate, gross payThis example introduces the conditional control structure. On the basis of the true/false question asked in line 3, we execute line 3.1 if the answer is True; otherwise if the answer is False we execute the lines subordinate to line 4 (i.e. line 4.1). In both cases we resume the pseudo-code at line 5.
9.
FlowchartA flowchart isa diagrammatic representation that illustrates the sequence of operations to be performed to get the solution of a problem. Flowcharts are generally drawn in the early stages of formulating computer solutions. Flowcharts facilitate communication between programmers and business people. These flowcharts play a vital role in the programming of a problem and are quite helpful in understanding the logic of complicated and lengthy problems. Once the flowchart is drawn, it becomes easy to write the program in any high level language. Often we see how flowcharts are helpful in explaining the program to others. Hence, it is correct to say that a flowchart is a must for the better documentation of a complex program.
10.
Basic SymbolsRounded box- use it to represent an event which occurs automatically. Such an event will trigger a subsequent action, for example `receive telephone call’, or describe a new state of affairs.Rectangle or box - use it to represent an event which is controlled within the process. Typically this will be a step or action which is taken. In most flowcharts this will be the most frequently used symbol.Diamond - use it to represent a decision point in the process. Typically, the statement in the symbol will require a `yes' or `no' response and branch to different parts of the flowchart accordingly.Circle - use it to represent a point at which the flowchart connects with another process. The name or reference for the other process should appear within the symbol.
11.
GUIDELINES FOR DRAWINGA FLOWCHARTFlowcharts are usually drawn using some standard symbols; however, some special symbols can also be developed when required.Start or end of the programComputational steps or processing function of a programInput or output operationDecision making and branchingConnector or joining of two parts of programMagnetic TapeOff-page connectorFlow lineAnnotationDisplay
13.
Draw a flowchartto find the largest of three numbers A,B, and C.