GoConqr has a new look! Let us know what you think.

Mind map

Control Structures

Ramón Cordova Spanish

Map content

Control Structures

  1. A control structure is a block of programming that analyzes variables and chooses a direction in which to go based on given parameters. Flow control determines how a computer will respond when given certain conditions and parameters.

  2. As

    • IF THEN
      • IF variable is true THEN take this course of action.
        • If the variable indeed holds a value consistent with being true, then the course of action is taken. If the variable is not true, then there is no course of action taken.
    • IF THEN ELSE
      • IF variable is true THEN take this course of action ELSE call another routine
        • If the variable is true, it takes a certain course of action and completely skips the ELSE clause. If the variable is false, the control structure calls a routine and completely skips the THEN clause.
    • While & Do-While Loops
      • A WHILE loop is a process in which a loop is initiated until a condition has been met. This structure is useful when performing iterative instructions to satisfy a certain parameter.
        • Precondition: variable X is equal to 1 WHILE X is not equal to 9 Add 1 to X
      • A DO-WHILE loop is nearly the exact opposite to a WHILE loop. A WHILE loop initially checks to see if the parameters have been satisfied before executing an instruction. A DO-WHILE loop executes the instruction before checking the parameters.
        • DO Add 1 to X WHILE X is not equal 9
    • For Loops
      • A FOR loop is an extension of a while loop. A for loop usually has three commands. The first is used to set a starting point (like x = 0). The second is the end condition (same as in a while loop) and is run every round. The third is also run every round and is usually used to modify a value used in the condition block.
        • FOR X is 0. X is less than 10. add 1 to X.
          • This loop would be run 10 times (x being 0 to 9) so you won't have to think about the X variable in the loop you can just put code there.
  3. Example using traffic flow as a model.

    • A vehicle is arriving at an intersection. Thus, the precondition is the vehicle is in motion. Suppose the traffic light at the intersection is red. The control structure must determine the proper course of action to assign to the vehicle.
      • Precondition: The vehicle is in motion.
        • Treatments of Information through Control Structures: -Is the traffic light green? If so, then the vehicle may stay in motion. -Is the traffic light red? If so, then the vehicle must stop.
          • End of Treatment
            • Postcondition: The vehicle comes to a stop.

Information

Description
Mind Map on Control Structures, created by Ramón Cordova on 20/02/2019.
Created by
Ramón Cordova
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?