ICA-CP: Syntax of if
State: The if statement executes commands if the condition is met.
Elaborate:
Here is the syntax:
if ( [the condition is met] )
{
// do what is between the braces
}
eXemplify:
Here's an example from Karel the Robot:
if (frontIsBlocked)
{
turnleft();
}
Illustrate: Using a if statement is like being a ticket collector at a Giants game. If you meet the condition of having a ticket, the ticket collector takes your ticket. Then you can go into the game.
0 Comments:
Post a Comment
<< Home