An If/Else statement is a man waiting to be woken up.
Instructions: Move the magnet up and down the box. If you put the magnet on the top of the box then the man is awake. But if you put the magnet on the bottom of the box then the man is sleeping ready to be woken once again buy the movement of the magnet.
An if/Else statement is a piece of code in a program that will run when something triggers it such as a movement, mouse click or a value etc. The statement has two parts to it an IF and an Else. When the statement has been triggered the program will check the statement to see if it should run the IF part of the statement or the Else part. This piece explains that an If statement is like a man ready to be woken up. It shows that an if statement is waiting in a pile of code ready to be triggered buy something which will make it run. In this instance the trigger is the magnet which wakes the man up or “runs the IF statement” or Else “It doesn’t run” and he stays asleep. The Man being awake represents the If statement running and the man lying down represents the else part of the statement.
Pseudocode
If (magnet=top of the box)
{
Man is awake;
}
Else
{
He is still sleeping;
}
No comments:
Post a Comment