-
-
Notifications
You must be signed in to change notification settings - Fork 9
If Statement
IsaacShelton edited this page Mar 21, 2022
·
1 revision
If statements are used to conditionally execute a block of code
if condition {
// ...
}
if(condition){
// ...
}
if condition, // ...
if condition // ...
if(condition) // ...
if(condition), // ...
If the condition is true
, then the code inside the block will be executed
If the condition is false
, then other code can be executed instead by specifying an else
block
else {
// ...
}
} else {
// ...
}
else // ...
else if // ...
elif // ...
import basics
func main {
age int = scanInt("How old are you? ")
if age >= 18 {
print("You are an adult")
} else {
print("You are a child")
}
}