Computer Applications
What is an if-statement ? Give two examples.
Scratch
3 Likes
Answer
The if block from Controls category is used when we have to take an action depending upon a certain condition. It allows a program to execute certain actions only if a specific condition is true. If the condition is false, the actions within the if-statement are skipped.
Consider the following examples:
1. If we want our sprite to move to the center of the stage when it touches the edge of stage, we can use the given script:
if touching edge then
go to x : 0 y : 0
2. If we want our sprite to say "You win" when it touches another sprite (ball), we can use the given script:
if touching ball then
say "You win"
Answered By
1 Like
Related Questions
What is a loop ?
- A loop is a conditional statement that needs to be directed for it to work
- Tells sprites what to do
- Changes the font a word
- It's the hole in the ground
What is an infinite loop or continuous loop ?
Carefully go through some sample scripts given below. What is happening in each of these scripts ?
How are following two scripts different from one another ?