What are the three basic structures of structured programs?
The three basic structures are: 1. Sequential structure, each operation in the program is executed in the order in which they appear; 2. Selection structure, the processing steps of the program branch, and they need to be based on certain conditions. Select one of the branches to execute; 3. Loop structure, the program repeatedly performs one or more operations until a certain condition is false (or true) before the loop can be terminated.
Structured programming is the basic principle for detailed design focusing on module function and process design. Structured programming is a subset of procedural programming that uses logical structures in written programs to make understanding and modification more efficient and easier.
Structured programming adopts a top-down, step-by-step refinement design method. Each module is connected through a "sequence, selection, loop" control structure, and has only one entrance and one exit.
The principle of structured programming can be expressed as: program = (algorithm) (data structure).
The algorithm is an independent whole, and the data structure (including data type and data) is also an independent whole. The two are designed separately, focusing on algorithms (functions or processes).
With the development of computer technology, software engineers are paying more and more attention to the expression of the overall relationship of the system, so data model technology has emerged (treating data structures and algorithms as an independent functional module), which is oriented to The prototype of object programming.
There are three basic structures of structured programs: sequential structure, selection structure and loop structure.
1. Sequential structure
The sequential structure indicates that the operations in the program are executed in the order in which they appear. The characteristics of this structure are: the program starts from the entry point a and performs all operations in sequence until the exit point b, so it is called a sequential structure.
2. Selection structure
The selection structure indicates that there are branches in the processing steps of the program, and it needs to select one of the branches for execution based on a specific condition. There are three types of selection structures: single selection, double selection and multiple selection.
3. Loop structure
The loop structure means that the program repeatedly performs one or more operations until a certain condition is false (or true) before the loop can be terminated. The most important thing in a loop structure is: under what circumstances is the loop executed? What operations need to be performed in a loop? There are two basic forms of loop structures: when-type loops and until-type loops.
When-type loop: It means to judge the condition first, execute the loop body when the given condition is met, and the process will automatically return to the loop entrance at the loop terminal; if the condition is not met, exit the loop body and directly reach the process exit. Because it is "execute the loop when the condition is met", that is, judge first and then execute, it is called a when loop.
Until loop: It means that the loop body is executed directly from the entrance of the structure, and the condition is judged at the loop terminal. If the condition is not met, return to the entrance to continue executing the loop body until the condition is true before exiting the loop and reaching the process. At the exit, it is executed first and judged later. Because it is "until the condition is true", it is called a until loop.
The above is the detailed content of What are the three basic structures of structured programs?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The purpose of a loop is to repeatedly execute a certain piece of code. Using loops can reduce programming pressure, avoid code redundancy, improve development efficiency, and facilitate later maintenance. The while loop is the simplest loop statement provided in JavaScript. Let's learn about the use of while loops and do-while loops.

There is a new loop statement in es6: "for of" loop. The "for..of" statement can loop through the entire object and is a loop of a series of values produced by the iterator; the value of the "for..of" loop must be an iterable (iterable), and the syntax "for(current value of array){...}". The for-of loop not only supports arrays, but also supports most array-like objects; it also supports string traversal, and traverses strings as a series of Unicode characters.

There are three basic structures of the program: 1. Sequential structure, each operation in the program is executed from top to bottom in the order in which it is arranged in the source code; 2. Selection structure, after judging based on a specific condition, select one of them One execution; 3. Loop structure. In the program, one or more operations need to be executed repeatedly, and the loop will not stop until the condition is false or true.

In the previous article "JS Loop Learning: The Use of While Loop Statements (Detailed Examples)", we briefly learned about the while loop and the do while loop, and today we will introduce another kind of loop-the for loop statement. I hope it will be useful to everyone. Helped!

The basic structure required by a structured program does not include "GOTO jumps". Structured programming is the basic principle for detailed design focusing on module function and process design. It has three basic structures: sequential structure, branch structure and loop structure, excluding goto jumps; goto jumps are only for branch structures. One, and also a keyword. The goto statement is usually used in conjunction with conditional statements and can be used to implement conditional transfers, form loops, and jump out of loop bodies.

Learn loop structures: for, foreach, and while statements In programming, loop structures are essential because they allow the program to repeatedly execute a section of code, thereby saving time and amount of code. In programming languages such as PHP, Java, and C#, there are three loop structures: for, foreach, and while statements. In this article, we will introduce these three loop structures respectively, as well as their application scenarios and some usage techniques in programming. for loop The for loop is one of the most basic loop structures.

In the previous article, we took you to learn several loop control structures in JS (while and do-while loops, for loops). Let’s talk about the break and continue statements to jump out of the loop. I hope it will be helpful to everyone!

In Python's loop structure, the else block is used to execute a specific piece of code when the loop ends normally. If the loop is interrupted by a break statement, the code in the else block will not be executed. Using else blocks can make the code clearer and easier to understand, and can perform some necessary operations after the loop ends.