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.

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.

Article image Flow control structures: decision

Next page of the Free Ebook:

11Flow control structures: decision

3 minutes

Obtenez votre certificat pour ce cours gratuitement ! en téléchargeant lapplication Cursa et en lisant lebook qui sy trouve. Disponible sur Google Play ou App Store !

Get it on Google Play Get it on App Store

+ 6.5 million
students

Free and Valid
Certificate with QR Code

48 thousand free
exercises

4.8/5 rating in
app stores

Free courses in
video, audio and text