answersLogoWhite

0


Best Answer

Control Structures change the flow of a program.

Control Structures can be combined using what is known as Nesting.

In Nesting a control structure is put within another Control Structure

Example

If (x==y ) If (y==z) then do something

While(X is Not 0) While ( Y is Not 100 ) then do something.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the two ways in which control structures can be combined?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are the two ways strings can be combined to create a new string?

Concat()


What are the two ways in which a workplace can be controlled?

According to Richard Walton (1991), the work force can be managed in two ways, one based on control and the other based on commitment.


Selection and Repetition Control Structures Prepare a 3 to4 page paper that addresses the following- Selection Control Structures Explain how selection control structures increase the usefulness and?

SELECTION CONTROL STRUCTURES AND THEIR USEA selection control structure is used to make a choice between two or more actions, depending on whether a condition is true or false. This condition is expressed with one of the relational operators like less than, greater than, equal to (,=,,)etc. Adding selection structures makes the program a lot more structured and also gives the programmer a lot of flexibility. There are mainly four different kinds of selection control structures.1. Simple selection2. Simple selection with null false branch3. Combined selection4. Nested selectionLet us go through the control structures one by one relating them to real life examples.1>Simple selection (Simple If statement):Simple selection occurs when a choice is made between two alternate paths, depending on the result of a condition being true or false. The important keywords used are IF, THEN, ELSE and ENDIF.Let us take the example of a city where we want to count the sex ratio. For that we need to calculate the number of males and females. A pseudocode to solve the problem using a simple selection structure would be as followsIF Gender = "M"THENIncrease Male-Count by oneELSEIncrease Female-Count by oneENDIF2. Simple Selection with Null False Branch (null ELSE statement):These kind of selection structures are used when we a task is performed only when a particular condition is true. If the mentioned condition is false, then there is no execution or processing and the IF statement is skipped or bypassed. The ELSEclause is not used. Thus the selection is between executing or bypassing an action. The important keywords used are IF, THEN, ELSE and ENDIF.Let us take an example where we want to count the number of adults in a city. A pseudocode to solve the problem using a simple selection with null false branch would be as followsIF AGE > 18THENIncrease Adult Count by oneENDIF3. Combined Selection(combined IF statement):A combined IFstatement is one that contains multiple conditions, each connected with the logical operators AND or OR.If the connector AND is used to combine two conditions, then both conditions must be true for the combined condition to be true.First let us take an example of combined selection using AND. Say we want to count the number of females above the age of 18.The pseudocode would beIF Age > 18 AND Gender = "F"THENIncrease Female-Adult-Count by oneENDIFIf the connector ORis used to combine two conditions, then only one of the conditions needs to be true for the combined condition to be considered true.Say we want to determine the tickets that can be priced at half rate for children and senior people. The pseudocode would beIF Age < 12 OR Age > 65THENAdd 1 to Half-Price-CountENDIF4. Nested Selection (nested IF statement) A nested selection occurs when the word IF appears more than once within an IFstatement. A nested selection (IF) occurs when either the true of false branch of one If has another IF statement embedded within it.This kind of structure is used when there are multiple conditions to choose from. For example while calculating tax the tax rate varies according to the gross salary.A simple pseudocode to count number of male and female adults will beIF Age > 18IF Gender = "F"THENIncrease Female-Adult-Count by oneELSEIF Gender = "M"THENIncrease Male-Adult-Count by oneENDIFENDIFREPITITION CONTROL STRUCTURES AND THEIR USEThis type of control structures specify a block of one or more statements that are repeatedly executed until a condition is satisfied. These are also called iteration control structures. There are three different ways that a set of instructions can be repeated, and each way is determined by where the decision to repeat is placed:- at the beginning of the loop (leading decision loop)- at the end of the loop (trailing decision loop)- a counted number of times (counted loop)1. Leading Decision Loop:In such loops the testing of the condition is at the beginning of the loop. Examples are DOWHILE loops. The only way to terminate the loop is to render the DO WHILE loop false. Consider a program to sell tickets. The program should sell tickets while there are tickets available. In such types of loops Leading Decision loops can be used to sell tickets until tickets are 0 which can be used as the termination statement.2. Trailing Decision Loop:In such structures the testing of condition is done at end of loop except that the logic to keep on repeating is same as in case of other repetition structures. REPEAT&hellip;UNTIL is an example of trailing decision loop. In trailing loops the statements are executed at least once before the condition is tested. These loops are sued in almost all kinds of computer program for e.g to print student records, to continue taking input until a certain limit, etc.3. Counted Loop:These are also known as DO or FOR loops. In such kind of repetition structures the programmer knows in advance the exact number of loop iterations. The loop execution is controlled by an important variable called the loop index. Say a programmer wants to input the salary record for 20 individuals. He will give the counted loops a high priority because he knows hp many times he wants to repeats the loop.Finally we can conclude that selection control structures and repetition control structures find their use in almost any application. Using them wisely and judiciously depends on the person who is going to use these loops. Proper implementation of loop structures can reduce program complexity and cost a lot.


What are the 5 types of commands in a drill?

Two part Combined Supplementing Directive Mass


What are the two kinds of walls that hold up roofs of frame structures?

load bearing

Related questions

What are two ways in which control structures can be combined?

Control Structures can be combined by a process called Nesting. Example: if (x==true) if(y==true) { Foo() }


What are the two ways strings can be combined to create a new string?

Concat()


What are two ways that mixtures differ from compuonds?

Compounds are two or more elements combined on a set ratio, and mixtures are not chemically combined, they are two or more substances mixed together


How many ways can a combined 6 be rolled with two standard dice?

5 :)


What two ways do religious structures often stand out in a landscape?

Religious structures often stand out in a landscape due to their distinctive architectural features, such as spires, domes, or intricate carvings, that make them easily recognizable. Additionally, their size and height often make them prominent landmarks visible from a distance.


What are two ways to control sound?

Depends


What are the two basic ways in representing linear structures in memory?

Data structures are classified as either linear or non linear, a data structure is said to be linear if its elements form a sequence, or, in other words, a linear list, there are two basic ways of representing such linear structures in memory, one way is to have the linear relationship between the elements represented by means of sequential memory locations, these linear structures are called arrays, the other way is to have the linear relationship between the elements represented by means of pointers or links, these linear structures are called linked lists.


What are three that ways to control enzymes?

One way to control an enzyme is by altering the number of enzyme molecules. Two other ways are by altering the enzyme activity and compartmentalization.


How many ways can a combined 4 be rolled with two standard dice?

Assuming you mean a sum of 4, there are three ways this can be done: (1, 3), (2, 2) and (3, 1).


Descibe two ways that you can control static discharge in your home?

touch it, or feel it,


What are two ways that researcher can avoid a biased sample?

experimental and control groups


What are the two ways in which a workplace can be controlled?

According to Richard Walton (1991), the work force can be managed in two ways, one based on control and the other based on commitment.