Free Ebook cover Basic to Advanced Logic Programming Course

Basic to Advanced Logic Programming Course

New course

50 pages

Flow control structures: sequence

Capítulo 10

Estimated reading time: 2 minutes

Audio Icon

Listen in audio

0:00 / 0:00

Flow Control Structures: Sequence

A program's flow control is what determines the order in which instructions are executed. In programming logic, flow control structures are essential to determine the path that the program will follow. Flow control structures can be divided into three types: sequence, selection, and repetition. In this chapter, we will focus on the sequence structure.

Understanding Sequence Structure

The sequence structure is the simplest of the flow control structures. It determines that the statements are executed from top to bottom, one after the other, in the order in which they appear in the code. That is, the program starts executing on the first line and continues sequentially until the last line.

For example, in a program that calculates the average of two grades, the sequence would be: read the first grade, read the second grade, calculate the average, and display the result. Each of these actions is a statement that will be executed in order, one after the other.

String Structure Example

To better illustrate, let's look at a practical example in Python programming language:

grade1 = float(input("Enter the first grade: "))
grade2 = float(input("Enter the second grade: "))
average = (grade1 + grade2) / 2
print("Average is", average)

In this example, the program starts reading the first grade (grade1), then reads the second grade (grade2), calculates the average, and finally displays the result. Each statement is executed in sequence, one after the other.

Continue in our app.

You can listen to the audiobook with the screen off, receive a free certificate for this course, and also have access to 5,000 other free online courses.

Or continue reading below...
Download App

Download the app

Importance of Sequence Structure

The sequence structure is the basis for any program. Even if a program uses other flow control structures such as selection and repetition, it will still have a sequence of statements that will be executed in order.

That's why it's important to understand the sequence structure well before moving on to the more complex flow control structures. Mastering sequence structure is the first step to becoming a good programmer.

Conclusion

The sequence structure is a fundamental part of programming logic. It determines the order in which a program's instructions are executed, proceeding from top to bottom, one after the other. Learning sequence structure is the first step in understanding how programs work and how to control their flow of execution.

We hope this chapter has helped you better understand the sequence structure. In the next chapter, we'll move on to selection and repetition flow control structures. Stay tuned!

Now answer the exercise about the content:

What is the function of the sequence structure in programming logic?

You are right! Congratulations, now go to the next page

You missed! Try again.

The sequence structure ensures that statements are executed from top to bottom, in the exact order they appear. This orderly execution is fundamental for the logical flow of any program.

Next chapter

Flow control structures: decision

Arrow Right Icon
Download the app to earn free Certification and listen to the courses in the background, even with the screen off.