What is the process of Logic Structure?

Logic Structure

A Logic structure is essentially a block of programming that examines variables and determines a direction in which to move depending on specified parameters. The phrase flow control specifies the direction the program goes (which way program control “flows”) (which way program control “flows”). Hence it is the primary decision-making process in computers; It is a forecast.

Types of Logic Structure

Algorithms and their equivalent computer programs have more easily understood if they mainly use self-contained modules and three types of logic, or flow of control, called.

Sequence logic, or Sequential flow

Selection logic, or conditional flow

Iteration logic, or repetitive flow

These three types of logic have discussed below, and in each case, we show the equivalent flowchart.

Sequence Logic (Sequential flow)

The rationale of the sequence had explored before. The modules have performed in the obvious sequence unless otherwise instructed. The order in which the modules have drawn may shown openly, via numbered stages, or implicitly. (See pictures 2-3). This basic flow pattern usually has followed by most processing, even complicated situations.

Selection Logic (Conditional flow)

The selection logic uses a variety of conditions that allow one of a number of possible modules to selected. The structures implementing this logic have referred to as conditional structures or structures. To clear, the end of such a structure has often indicated by the declaration.

[End of If Structure]

These conditions are described in three types, which have individually explored.

  1. Single alternative. This structure has the form

If condition, then:

[Module A]

[End of if structure]

If the condition is present, then Module A has run, which could consist of a further statement; otherwise, Module A has skipped and the transfer of control to the next phase of the algorithm is controlled.

2. Double alternative. This structure has the form

If condition, then:

[Module A]

else:

[Module B]

[End of if structure]

If a condition is present, Module A will run, as shown in the flowchart; module B otherwise will executed.

If condition(1), then:

[Module A1]

else if condition(2), then:

[Module A2]

else if condition(M), then:

[Module AM]

else:

[Module B]

End of if structure]

The structural logic enables the execution of just one of the modules. Specifically, it executes either the module after the first condition or the module following the last sentence Else. More than three choices will hardly occur in actuality.

Example

The solution of quadratic equation

ax2+ bx+c=0

where a ≠ 0, have given by the quadratic formula

Logic

The quantity D=b2 – 4ac ha called the discriminant of the equation. If D is negative, then there are no real solutions. If D=0, then there is only one (double) real solution, x=-. If D is Positive, the formula gives the two distinct real solutions. The following algorithm finds the solutions of a quadratic equation.

Logic

Iteration (Repetitive flow)

One of two forms of structures with loops is the third type of logic. The following module has followed by a repeat statement for each type, termed the loop body. For clarity, the end of the structure has indicated by the declaration.

[End of loop]

There is a distinct discussion on each form of the loop structure.
The repeat-for-loop has controlled by an index variable, such as K. Normally the loop has the shape:

Here R is called the initial value, S the end value or test value, and T the increment. Observe that the body of the loop is executed first with K=R, then with K= R+T, then with K=R+2T, and so on. The cycling when K>S. The flowchart

Logic

Assumes that the increment T is positive; so that K decreases in value, then the cycling ends when K<S.

The repeat-while loop uses a condition to control the loop. The loop will usually have the form

Repeat while condition:

[Module]

[End of loop]

Note that the cycle continues until it is wrong. We highlight that the loop control condition has to be declared before the structure is first initiated and a declaration must be made on the body of the loop that alters the condition in order to finally halt the looping.

Logic