</>Learn to Write Code
LearnPseudocodeReal CodeLanguagesVideosCode TalkAbout
Learn → Programming Fundamentals → Program Structure & Sequence

Programming Fundamentals

01Variables02Operators03Input & Output04Sequence05Conditions06Loops07Functions08Objects
Lesson 4 of 8·Beginner

Program Structure & Sequence

Put instructions in an order the computer can follow from start to finish.

Related:sequencemainprogram flowstatementorder

A program is a sequence of instructions

Computers are very literal. If you give them several instructions, the order matters.

A sequence is simply the set of steps the program should run. Unless something changes the flow, the computer starts at the top and works downward.

  • Create a value.
  • Change the value.
  • Display the result.
Think of a recipe: doing the right steps in the wrong order can still produce the wrong result.
Try it: Write three plain-English steps for making a sandwich in the order they must happen.

Give the sequence a name

SEQUENCE groups the instructions that make up our program.

Pseudocode
SEQUENCE Start
    CREATE score AS 0
    CHANGE score TO 10
    SHOW score
END SEQUENCE

The same idea in Python

Python often puts the main sequence in a function named main and calls it when the file runs directly.

Python
def main():
    score = 0
    score = 10
    print(score)

if __name__ == "__main__":
    main()

The same idea in JavaScript

A small JavaScript file can simply execute its statements from top to bottom.

JavaScript
let score = 0;
score = 10;
console.log(score);

The same idea in C#

A traditional C# console program starts in Main.

C#
class Program
{
    static void Main()
    {
        int score = 0;
        score = 10;
        Console.WriteLine(score);
    }
}

The same idea in Java

A Java application starts in its main method.

Java
public class Program {
    public static void main(String[] args) {
        int score = 0;
        score = 10;
        System.out.println(score);
    }
}

The same idea in C++

A C++ application begins execution in main().

C++
int main()
{
    int score = 0;
    score = 10;
    std::cout << score << '\n';
    return 0;
}
Lesson 4 of 8 · Concept
← Previous Lesson: Input & OutputNext Lesson: Conditions →

Learn to Write Code

Learn the idea first, write it in pseudocode, then see how real programming languages express the same logic.

Learn

CurriculumPseudocode StandardLanguagesReal Code

Elsewhere

Code TalkAbout BriancodeBetter on YouTubeSupporting files on GitHubAdvertising & Promotions
© 2026 Learn to Write Code. Educational content and examples are provided for learning purposes.