This section contains 294 words (approx. 1 page at 300 words per page) |
A conditional control refers to a structure of an algorithm where conditions to be met are specified in a linear order. For all but the initial condition, a condition requires the preceding condition to be true. Conditional controls form the basis of algorithms that are used in the top-down design of programming languages such as C++. In this design, the major components of a solution are recognized first and the solution is expressed as a sequence of the major components and their related components.
"If" and "Then" are important components of the conditional control. As these operators imply, the second condition is dependent on the achievement of the first condition. Multiple conditions can be incorporated into a conditional control to permit a flexible and branching decision route. For example, condition controls would allow a scheme such as "if condition A is met then do B, but if condition A is not met but condition C is met, then do D, but if neither condition A or C is met then do E."
Conditional controls are also valuable in defining functions that involve the repetition of a step at certain times in the execution of an action.
The following is an example where use of conditional controls would be required. The task would involve the writing of a program to calculate the wage of an employee based on changing hours of weekly work. Payment is based on a set wage for a defined period with various overtime rates in effect for hours beyond the base period. The variable nature of the hours worked and the resultant payments require conditional statements.
The importance of conditional controls is reflected by their inclusion in a variety of programming languages, such as C++ and LISP.
This section contains 294 words (approx. 1 page at 300 words per page) |