>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
Docs7. Reusable Code with Functions

7. Reusable Code with Functions

Learn Reusable Code with Functions through beginner-friendly explanations, working GOCO examples, and their expected output.

7.1 What is a Function?

A function is a named block of code you can use over and over. You give it an input, and it does the job. Notice that a function must close with '}.' at the end.

goco
Function sayHello(Sentence name) {
Displaynl("Hello there, " + name + "!").
}.
// Using the function
sayHello("Tom").
sayHello("Jerry").

7.2 Getting Answers Back

Some functions do not do actions. They find answers and give them back to you using Return. You have to tell it what kind of box it Returns.

goco
Function getDouble(Number a) {
Return a * 2.
} Returns Number.
Number answer = getDouble(5).
Displaynl(answer).
Previous6. Loops: Doing Things Over and Over
Next8. Lists of Items: Arrays
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.