Computer Science

Pseudocode

Pseudocode is a high-level description of a computer program that uses natural language and simple constructs to outline the logic of the program. It is not a programming language, but rather a way to plan and design a program before writing actual code. Pseudocode is often used in the early stages of software development to help programmers think through the steps needed to solve a problem.

Written by Perlego with AI-assistance

5 Key excerpts on "Pseudocode"

  • Book cover image for: Foundations of Computing
    eBook - ePub

    Foundations of Computing

    Essential for Computing Studies, Profession And Entrance Examinations - 5th Edition

    • Pradeep K. Sinha, Priti Sinha(Authors)
    • 2022(Publication Date)
    • BPB Publications
      (Publisher)
    “Pseudo” means imitation or false and “Code” refers to the instructions written in a programming language. Pseudocode, therefore, is an imitation of actual computer instructions. These pseudo-instructions are phrases written in a natural language (e.g., English, French, German, etc.) that a computer cannot understand. However, Pseudocode uses a structure that resembles computer instructions. When a programmer uses Pseudocode for planning a program, he/she can concentrate solely on developing the logic of the program without worrying about the syntax for writing program instructions because Pseudocode does not have any syntax rules for formulating instructions. Once the programmer is convinced that the program logic is sound, he/she can convert the Pseudocode easily into a suitable programming language. Since the emphasis of Pseudocode is on program design, it is also known as Program Design Language (PDL). Pseudocodes for Basic Logic (Control) Structures During early days of program development, many programmers developed program logics for large programs with mazes of branches (jumps from one portion of the program to another) that altered the sequence of processing operations. Such programs are now referred to as “spaghetti code” because their program flowcharts appeared more like a plate of spaghetti than like logical analyses of programming problems. Understanding the logic of such programs was difficult for someone other than the developer, and even for the developer after a lapse of few months
  • Book cover image for: Programming Logic and Design, Introductory
    Pseudo is a prefix that means false, and to code a program means to put it in a programming language; therefore, Pseudocode simply means false code, or sentences that appear to have been written in a computer programming language but do not necessarily follow all the syntax rules of any specific language. • A flowchart is a pictorial representation of the same logical steps. Writing Pseudocode You already have seen examples of statements that represent Pseudocode earlier in this chapter, and there is nothing mysterious about them. The following five statements constitute a Pseudocode representation of a number-doubling problem: start input myNumber myAnswer = myNumber * 2 output myAnswer stop Using Pseudocode involves writing down all the steps you will use in a program. Usually, programmers preface their Pseudocode with a beginning statement like start and end it with a terminating statement like stop. The statements between start and stop look like English and are indented slightly so that start and stop stand out. Most programmers do not bother with punctuation such as periods at the end of Pseudocode statements, although it would not be wrong to use them if you prefer that style. Similarly, there is no need to capitalize the first word in a statement, although you might choose to do so. Pseudocode is fairly flexible because it is a planning tool, and not the final product. Therefore, for example, you might prefer any of the following: • Instead of start and stop, some Pseudocode developers would use other terms such as begin and end. • Instead of writing input myNumber, some developers would write get myNumber or read myNumber. • Instead of writing myAnswer = myNumber * 2, some developers would write calculate myAnswer = myNumber times 2 or myAnswer is assigned myNumber doubled. • Instead of writing output myAnswer, many Pseudocode developers would write display myAnswer, print myAnswer, or write myAnswer.
  • Book cover image for: Programming Logic & Design, Comprehensive
    May not be copied, scanned, or duplicated, in whole or in part. WCN 02-300 Using Pseudocode Statements and Flowchart Symbols When programmers plan the logic for a solution to a programming problem, they often use one of two tools: Pseudocode (pronounced sue-doe-code ) or flowcharts. • Pseudocode is an English-like representation of the logical steps it takes to solve a problem. Pseudo is a prefix that means false , and to code a program means to put it in a programming language; therefore, Pseudocode simply means false code , or sentences that appear to have been written in a computer programming language but do not necessarily follow all the syntax rules of any specific language. • A flowchart is a pictorial representation of the same logical steps. Writing Pseudocode You already have seen examples of statements that represent Pseudocode earlier in this chapter, and there is nothing mysterious about them. The following five statements constitute a Pseudocode representation of a number-doubling problem: start input myNumber myAnswer = myNumber * 2 output myAnswer stop Using Pseudocode involves writing down all the steps you will use in a program. Usually, programmers preface their Pseudocode with a beginning statement like start and end it with a terminating statement like stop . The statements between start and stop look like English and are indented slightly so that start and stop stand out. Most programmers do not bother with punctuation such as periods at the end of Pseudocode statements, although it would not be wrong to use them if you prefer that style. Similarly, there is no need to capitalize the first word in a statement, although you might choose to do so. Pseudocode is fairly flexible because it is a planning tool, and not the final product. Therefore, for example, you might prefer any of the following: • Instead of start and stop , some Pseudocode developers would use other terms such as begin and end .
  • Book cover image for: Computer Fundamentals - 8th Edition
    eBook - ePub

    Computer Fundamentals - 8th Edition

    Concepts, Systems & Applications

    • Pradeep K.Sinha, Pradeep K.Sinha, Priti Sinha(Authors)
    • 2004(Publication Date)
    • BPB Publications
      (Publisher)
  • Owing to the symbol-string nature of flowcharting, any change or modification in program logic usually requires a completely new flowchart. Redrawing a flowchart being a tedious task, many programmers do not redraw or modify the corresponding flowcharts when they modify their programs. This leaves a program and its flowchart in an inconsistent state. That is, the logic used in the program and that shown in its flowchart do not match. This defeats the purpose of use of flowcharts as documentation support for programs. To take care of this problem, many companies use software tools that generate flowcharts automatically from program code. These software tools read a program's instructions and draw an equivalent flowchart of its logic. This backward approach draws flowcharts from program codes mainly for documentation purpose.
  • There are no standards determining the amount of detail that should be included in a flowchart.
  • Because of such limitations, many organizations have reduced the amount of flowcharting used. In its place, they use alternative tools for program analysis, such as Pseudocode.

    Pseudocode

    What is Pseudocode?

    Pseudocode is another program-planning tool used for planning program logic. “Pseudo” means imitation or false and “Code” refers to the instructions written in a programming language. Pseudocode, therefore, is an imitation of actual computer instructions. These pseudo-instructions are phrases written in a natural language (e.g., English, French, German, etc.) that a computer cannot understand. However, Pseudocode uses a structure that resembles computer instructions. When a programmer uses Pseudocode for planning a program, he/she can concentrate solely on developing the logic of the program without worrying about the syntax for writing program instructions because Pseudocode does not have any syntax rules for formulating instructions. Once the programmer is convinced that the program logic is sound, he/she can convert the Pseudocode easily into a suitable programming language. Since the emphasis of Pseudocode is on program design, it is also known as Program Design Language (PDL
  • Book cover image for: Invitation to Computer Science
    Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. 12 Chapter 1 An Introduction to Computer Science algorithmically. That is, they do not yet know how to specify a solution for-mally in a detailed step-by-step fashion. As humans, we are able to do them simply by using the “algorithms” in our heads. To appreciate this problem, imagine trying to describe algorithmically exactly what steps you follow when you are painting a picture, composing a love poem, or formulating a business plan. Thus, algorithmic problem solving has many variations. Sometimes solutions do not exist; sometimes a solution is too inefficient to be of any use; sometimes a solution is not yet known. However, discovering an algorithmic solution has enormously important consequences. As we noted earlier, if we can create a correct and efficient algorithm to solve a problem, and if we encode it into a programming language, then we can take advantage of the speed and power of a computer system to automate the solution and produce the desired result. This is what computer science is all about. 1.3 Algorithms 1.3.1 The Formal Definition of an Algorithm The formal definition of an algorithm is rather imposing and contains a number of important ideas. Let’s take it apart, piece by piece, and analyze each of its separate points. ...a well-ordered collection. . . An algorithm is a collection of operations, and there must be a clear and unambiguous ordering to these operations. Ordering means that we know which operation to do first and precisely which operation to do next as each step is successfully completed. After all, we cannot expect a computing agent to carry out our instructions correctly if it is confused about which instruction it should be doing next. Consider the following “algorithm” that was taken from the back of a shampoo bottle and is intended to be instructions on how to use the product.
  • Index pages curate the most relevant extracts from our library of academic textbooks. They’ve been created using an in-house natural language model (NLM), each adding context and meaning to key research topics.