Font size
WorksheetsFunctions in RobotC
Total questions: 22
Worksheet time: 11mins
True or False: Functions save time and space by allowing common behaviors to be written as functions, and then run together as a single statement (rather than re-typing all the individual commands).
True
False
True or False: Functions must be created and then run separately.
True
False
Separating behaviors into different functions allows your code to follow your planning more easily (one function per behavior or even sub-behavior).
True
False
True or False: Through the use of ____________, multiple related (but not identical) tasks can be handled with a single, intuitive function.
semicolons
curly brackets
parameters
()
A function is created by “_______” it, and run by “calling” it.
initializing
declaring
creating
naming
Declare the function by using the word “_______”, followed by the name you wish to give to the function. It’s helpful to give the function a name that reflects the behavior it will perform.
par
int
var
void
Within the function’s ________ , write the commands exactly as you would normally. When the function is called, it will run the lines between its braces in order, just like task main does with the code between its own braces.
( )
[ ]
{curly braces}
;
Once you ________ your function, it acts like a new command in the language of ROBOTC. To run the function, simply “call” it by name
declare
initiate
type
decide
________ are a way of passing information into a function, allowing the function to run its commands differently, depending on the values it is given.
adjustables
jingemalaries
semicolons
Parameters
A parameter is declared in the same way that a variable is (type then name) inside the ______ following the function name
{ }
parentheses
[ ]
; and ;
The parameter value behaves like a “_____”. Whatever value is provided for the parameter when the function is called will appear here.
yellow card
placeholder
warning
equal sign
When the function is called, a _______ must be provided within the parentheses to take the place of the parameter inside the function.
variable
value
adjustable
letter
Not all functions are declared “____”. Sometimes, you may wish to capture a mathematical computation in a function, for instance, or perform some other task that requires you to get information back out of the function at the end. The function will “return” a value, causing it to behave as if the function call itself were a value in the line that called it.
var
void
int
str
Which of the following are true about functions
Performs a specific task
Groups related code for easy re-use
May have a return value and/or parameter(s)
Helps you to DRY up your code
Which of the following is most similar to a function?
Table of contents
An instruction manual
Class notes
An outline for a paper
What do variables and functions have in common?
They are strings of commands
They store instructions
They replace a value
They are coding shortcuts
If you are coding a robot to sing a song, which part can be replaced by a function?
chorus
verse
note
rhymes
When you declare a function you:
Repeat it
Run it
Define it
Combine it
A statement in a function can be most closely compared to:
A step in a recipe
A line in a poem
A brushstroke in a painting
A piece of assembled furniture
Programmers declare a function:
The first time a function is called
Every time a function is called
At the beginning of the code
At the end of the code
In RobotC, which of these characters separates statements in a function?
=
{
;
[
What does DRY stands for?
Don't rely on yourself
Don't repeat yourself
Do rely on yourself
Do repeat your functions
