Selection Statements-Dougs work
Sequence:A sequence process when writing programs is when an action or event takes place which then leads to the following action in order; this ensures that all steps are executed. An example of this is when there is a program that multiplies numbers together which would require the user to input the numbers then multiply them and then display the result on the screen to the user.
Iteration: is when processes are repeated . In programming iteration is used to execute a certain piece of code until its requirement is met. Almost every programming language utilises this technique as it reduces the amount of code needed to run to allow the program to carry out a certain task. For loops and while loops are commonly used by software developers to carry out the iteration technique.
If-else: An if statement is used to check a condition and if the condition is true, we run a block of statements called the if block, else we process another block of statements called the else block but the else clause is optional. You use if to specify a block code to be executed, if a specify condition is true. Use else to specify a block of code to be executed, if the same condition is false.
What is the use of If-then-else? Else statement is encountered, condition is tested. If condition is true, the statements following then are executed. If condition is false, each Elself statement if there are any is evaluated in order. An example of if-then-else is shown below.
IF ( x > 10 ) THEN
Print ( x )
ELSE
x = x + 1
END
This is a small example of what I have personally done on arduino.
Switch Statement: A switch statement allows the value of a variable or expression to change the control flow of program execution via a multi-way branch. The switch statement can include any number of case instances, but no two case constants within the same switch statement can have the same value. Below shows an example of a switch statement.
Comments
Post a Comment