Page 86 - 2502_Pakistan-kifayat_C-6
P. 86

SEQUENTIAL STATEMENT


        A sequential statement in an algorithm is a type of statement where instructions are executed one after
        another in a specific order. In other words, each step in a sequential algorithm follows the previous
        one, and each instruction is executed exactly once. This is the most straightforward type of algorithm
        structure, where actions are performed in a linear sequence, with no branching or looping.

        Why are Sequential Statements Important?

        Sequential statements are crucial in algorithmic thinking because they form the foundation of more
        complex algorithms. Without a basic understanding of how instructions follow one another, it would be
        challenging to understand more advanced control structures like loops and conditionals.

        In programming, sequential statements ensure that instructions are executed in the correct order,
        making the algorithm easier to follow and debug. They are the most basic and essential component of
        any algorithm.

        Examples of Sequential Statement Algorithms

        Let’s look at examples to understand the concept of sequential statements.

        Example 1: Watering a Plant
        Algorithm:

        Step 1:    Start.

        Step 2:    Pick up the watering can.
        Step 3:    Fill the watering can with water.

        Step 4:    Carry the watering can to the plant.

        Step 5:    Pour water into the soil near the roots.

        Step 6:    Stop pouring when the soil is moist (not flooded).
        Step 7:    Put the watering can back in its place.

        Step 8:    Stop.

        Example 2: Adding Two Numbers
        Algorithm:

        Step 1:    Start.

        Step 2:    Input the first number (Num1).

        Step 3:    Input the second number (Num2).
        Step 4:    Add Num1 and Num2 (Result = Num1 + Num2).

        Step 5:    Print "Result".

        Step 6:    Stop.






            84  Premium Edition-VI
   81   82   83   84   85   86   87   88   89   90   91