|
||||||
Control Structures in ProgrammingAn Explanation of the Three Basic Structures Found in Programs
For programmers it is essential to understand the three control structures, sequence, repetition and selection which are the elementary building blocks for all programs.
Beginners can find Programming very confusing, Just like any other subject, there are a lot of new concepts to understand and lots of new terminology to learn. One of the most basic concepts in programming is control structures. There are three control structures and all programmers must learn what they are and how they can be used. These three basic structures can be used to develop any kind of program and they are explained below. Sequential ProgrammingThe most straightforward control structure is the sequence. A list of what to do, step by step. For example:
In pseudocode:
Repetition in ProgrammingRepetition is also called iteration and is used when something is repeated over and over again, so anything where the program goes round in a loop. Typically programmed using code such as WHILE, REPEAT and FOR statements. For example:
In pseudocode:
Another example: to write out numbers 1 to 10
NOTE: a FOR loop is used when it is known exactly how many times to go round the loop Selection in Programming : Making DecisionsSelection is used to make a decision to go down one path or another, often programmed using code such as an IF statement, or a CASE statement. For example: To Pack my bag for work)
In pseudocode:
Another example using a CASE:
Sometimes there is confusion between the Repetition and Selection statements, as both use a condition. A condition is a test, resulting in true or false. One way of describing the difference is that when making a selection, the condition is only ever tested once. When used in repetition, the condition is tested a number of times, every time the program decides whether to loop. Beginners who take the time to learn the basic building blocks of programming will find coding in new languages easier and developing computer programs requires an understanding of the three basic control structures outlined above.
The copyright of the article Control Structures in Programming in Computer Programming is owned by Dawn Brewer. Permission to republish Control Structures in Programming in print or online must be granted by the author in writing.
Comments
Jun 24, 2009 10:30 PM
Guest :
Sep 1, 2009 10:41 AM
Guest :
2 Comments
|
||||||
|
|
||||||
|
|
||||||