An example of process in steps - Pseudo code

To wrote a program that will enable computer to simulate specific process we must first understand the process and have it broken down tobasic steps, which we will line up in proper order. For a description of each step in the process we use an ordinary spoken language, thesimpler the better for the further study of the process. When the entire description of the steps is agreed in a specific order and steps aredefinitely numbered, we obtain the pseudo code which is then used to develop programs that will simulate the investigated process.Remember what is a Computer program.

Here we shall do that in one simple example.

PROCESS OF MAKING TEA

Think of ways to prepare tea.

We need the court for warm up the water (pot),

the court for tea consumption (cups),

heating body (hotplate), certain type of tea, water and time.

The process consists of the following steps:

1. Take the pot

2. Pour water into the pot

3. Put the pot on the heating body

4. Turn on the hotplate and wait for water to boil

5. Put tea in a cup

6. When the water boils in a pot, pour the water over tea into a cup and wait 10 minutes

7. Turn off the hotplate

8. Drink tea

On this basis, to prepare the tea it was necessary only 8 steps that are executed in the above mentioned sequence.

Is this true and is this correct sequence of steps ?

Of course not. To arrive at a precise definition of steps and their sequence is required much more detailed analysis.

For example what if the pot is hollow or there is no water or no electricity.

Whether is to first turn off hotplate and then remove the pot?

Now we know that we have not defined any step that leads to making tea process break because of a lack

or an undesirable case in the process.

Let's try again:

1. Take the pot

1.1 If the pot is hollow end process

2. Do you have the water

2.1 If there is water pour water into the pot

2.2 If there is no water stop the process

3. Put the pot on the heating body

4. Do you have electricity

4.1 If there is electricity turn on the hotplate and wait for water to boil

4.2 If there is not stop process

5. Put tea in a cup

6. When the water boils in a pot, pour the water over tea into a cup and wait 10 minutes

7. Turn off the hotplate

8. Is 10 minutes passed

8.1 If not go to step 8

8.2 If yes process is continued , next step

9. Drink tea

In this sequence of steps we have defined the steps that allow the process to terminate in the event of a shortfall. This is done by asking questions and offering answers that determine the future course of the process (steps of 1.1., 2, 2.1. 2.2, 4, 4.1. 4.2), it is usually calledin programming conditional branching (If. .. then. else ..). Finding and defining this type of steps in the process is critical and extremelyimportant because if you can not find any possibility that the process is complete as it should for some strange reason, the program that was later derived from the pseudo code-a will not be good.

Occurs the case , for example, negative value under the square root, or attempted division by zero, or even blocks because of the impossibility of further execution.

In steps 8, 8.1 and 8.2 is so called iteration (repetition until conditions fulfilled), which means that step 8 is repeated until the condition isfulfilled. In the real computer program it is called a Loop.

Of course watching the pseudo code we come to the conclusion that we could introduce the steps of the process "Start" and "End"

of the process, and that all steps that require interruption of the process should be directed to the end of the process step.

Well then:

0. Start of the process

1. Take the pot

1.1 If the pot is hollow , go to Step 10

2. Do you have the water

2.1 If there is water pour water into the pot

2.2 If there is no water, go to Step 10

3. Put the pot on the heating body

4. Do you have electricity

4.1 If there is electricity turn on the hotplate and wait for water to boil

4.2 If there is not, go to Step 10

5. Put tea in a cup

6. When the water boils in a pot, pour the water over tea into a cup and wait 10 minutes

7. Turn off the hotplate

8. Is 10 minutes passed

8.1 If not, go to step 8

8.2 If yes process is continued , next step

9. Drink tea

10. End of the process

Now, we are within PSEUDO CODE defined something called a conditional jump (or jump action) on the step when the condition is satisfied.Study the steps 1.1, 2.2, 4.2 and 8.1 and get conclusion how our process works. Also try to define yourself steps to restart the processbased on previously acquired knowledge. If you do not know how see a solution.

The solution:

You should establish the steps 9.1, 9.2 and 9.3.

9.1 Do you want to cook tea again

9.2 If you do , go to step 0

9.3 If you do not , go to step 10

Step 9.3 is not necessary becouse it relates to the latest step in a series and therefore, if the condition is not met, an affirmative answer to the question in step 9.1, the process ends automatically by moving to step 10

This pseudo code can be written for each observed process, provided that you understand its mode of operation,

after which you can make the appropriate computer program.

Try to create a pseudo code for solving a mathematical problem. Let's solve quadratic equations.

All the best,

Author