>GOCO IDE
  • Home
  • Docs
Download
Documentation
Documentation
01Chapter 1: Basics02Chapter 2: Variables & Types03Chapter 3: Input and Output04Chapter 4: Math and Operators05Chapter 5: Making Decisions06Chapter 6: Repeating Parts (Loops)07Chapter 7: Functions08Chapter 8: Arrays (Lists)09Chapter 9: Standard Libraries
Docs5. If Statements and Choices

5. If Statements and Choices

Learn If Statements and Choices through beginner-friendly explanations, working GOCO examples, and their expected output.

5.1 The If, Elseif, and Else rules

Programs can make smart choices. It will check a rule. If the rule is True, it does the action. If not, it can check another rule using Elseif or do a default action using Else.

goco
Number age = 10.
If (age > 18) {
Displaynl("You are an adult.").
}
Elseif (age == 18) {
Displaynl("You just became an adult!").
}
Else {
Displaynl("You are a kid.").
}

5.2 Using Switch for Many Choices

When you have lots of exact choices to pick from, a Switch is cleaner than writing many If rules.

goco
Number luck = 2.
Switch(luck) {
Case(1) {
Displaynl("Gold Coin!").
}
Case(2) {
Displaynl("Silver Coin!").
}
Default {
Displaynl("No Coin!").
}
}
Previous4. Doing Math and Comparing Things
Next6. Loops: Doing Things Over and Over
GGOCO IDE

Write real code, compete in ranked battles, and level up your problem solving in one editor.

Stay updated

Get product updates and new learning resources. No spam.

Product

  • Home
  • Docs
  • Download IDE

Account

  • Sign in
  • Create account
  • Add a review
  • Send a suggestion

Contact

+91 93269 63378kancorp.inc@outlook.com
KanCorp Inc, India
© 2026GOCO IDE™. All rights reserved.Made withby KANCorp Inc.