Friday, March 1, 2013

Program Control Structure Concept

This tutorial uses JavaScript Language to demonstrate the underlying concepts. You may also try the JavaScript interactive console at http://www.squarefree.com/shell/ .

1) To solve programming problems, programmers normally write a list of statements.

2) By default, computer execute the statements sequentially from top to bottom of the list. However, some solutions are not straightforward and sequential steps could not solve them. Therefore, a Program Control Structure Concept is introduced.

2) Program Control Structure defines how the execution control move from one statement to another.

3) In general, there are three types of Control Structure:
3a) Sequential 
3b) Selection
3c) Loop

By using the combination of these three Control Structures, programmers would now be able to write most solutions.

4) Sequential Control Structure
4a) The following shows an example of program statements: 4b) See the output at http://ideone.com/u0TQIG.

5) Selection Control Structure
5a) The following shows an example of program statements:
5b) See the output at http://ideone.com/ES55HX.

6) Loop Control Structure.
6a) The following shows an example of program statements:
6b) See the output at http://ideone.com/LCNPbQ .









No comments:

Post a Comment