Cycle (Programming

Visual cycle in programming . The cycle is one of the most important basic programming structures , as it is present in many problems. In structured programming there are three types of basic cycles: determined, avoidable indeterminate and inevitable indeterminate; On the other hand, the visual programming brings with it a revolutionary change in this structure, since the one who controls when the cycle ends is the user himself, activating an event that means the break of the cycle.

Summary

[ hide ]

  • 1 Essential stages
  • 2 Application of the stages
  • 3 In visual programming
  • 4 Programming of processes before the cycle
  • 5 Sources
  • 6 See also

Essential stages

As an initial basis for programming the cycle structure, the programmer should know that there are three essential stages:

  1. Before the cycle: Initialization processes are carried out here, for example: adder at zero, counter at zero, production at 1, greater than a small value, less than a large value, etc.
  2. During the cycle: Here the data is entered and the accumulation operations and repetitive processes are performed, for example:
  3. counter +1 b.ßcounter   adder + data c.ßadder   producer * data d.ßproducer  If greater < data e.ßdata then greater  If less> dataßdata then less
  4. After the cycle: Here the final processes and impressions are carried out, for example:
  5. adder / counter g.ßaverage  Show average h.  counter1 / counter2 * 100 i.ßpercentage  Show percentage j. Show greater k. Show minor.

Application of the stages

These steps apply to the cycle structure regardless of the type of cycle being programmed, for example:

  1. Certain cycle.

Initialization processes. (Before the cycle) To <vc> ß <vi> until <vf> do repetitive processes. (During the cycle) End for. Final processes. (After the cycle)

  1. Unavoidable indeterminate cycle.

Initialization processes. (Before the cycle) Repeat Repetitive processes. (During the cycle) (The output must be guaranteed) Until <condition> Final processes. (After the cycle).

  1. Avoidable indeterminate cycle.

Initialization processes. (Before the cycle) While <condition> do repetitive processes (During the cycle) (The output is guaranteed) End While final processes. (After the cycle).

In visual programming

Control of the cycle is carried out by the user of the program, that is, there are events that guarantee the cycle and while they are being activated, the cycle is taking place and when an event is activated to see the results, the cycle ends and these are displayed. From the above reasoning, it must be established that:

  1. In the event that the cycle takes place, the processes carried out during the cycle must be programmed.
  2. In the event that shows the results, the processes that take place after the cycle must be programmed.

Process programming before the cycle

The programming of processes before the cycle are carried out. A widely used possibility is the form’s On_Activate event or another auto-start event. An example of the theory explained above is: The calculation of the grade point average of a group of students.

  1. First, we start by discussing a visual design for the program.

An idea can be an input box to enter the ratings, a button to Repeat the input, another button to show the Average in an output box.

File: Calpro

input box to enter ratings

  1. Then you can go on to analyze the events where the processes are scheduled before, during and after the cycle.
  2. Event where processes are scheduled Before the cycle. procedure TForm1.FormActivate (Sender: TObject); begin s: = 0; c: = 0; end; b. Event where processes are scheduled During the cycle. procedure TForm1.Button1Click (Sender: TObject); var qual: real; {variable where the grade will be stored} begin calif: = strtofloat (edit1.text); {extract grade from input box} s: = s + grade; {repetitive process of accumulating the sum} c: = c + 1; {repetitive counting process} edit1.text: = ; {input box is cleaned}edit1.setfocus; {so that the user knows that they can enter again} end;
  3. Event where processes are scheduled After the loop: procedure TForm1.Button2Click (Sender: TObject); avg var: real; {variable avg where the average will be stored} begin avg: = s / c; {calculation of the average} edit2.text: = floattostr (prom); end; The known theory of structured programmingto elaborate the cycles, regarding the Before, During and After processes, are maintained in the visual programming, but they must be carried out in independent events:
  4. In the On_Activate event, the Before processes can be performed.
  5. In the event of a Repeat button, the During processes can be performed.
  6. In the event of a button to show results, the processes can be performed After.

This strategy allows us to state that the cycle ends when the user presses the button to show results, therefore this cycle is a cycle controlled by the user.

 

by Abdullah Sam
I’m a teacher, researcher and writer. I write about study subjects to improve the learning of college and university students. I write top Quality study notes Mostly, Tech, Games, Education, And Solutions/Tips and Tricks. I am a person who helps students to acquire knowledge, competence or virtue.

Leave a Comment