wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Functions in RobotC

Total questions: 22

Worksheet time: 11mins

Name
Class
Date
1.

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).

a)

True

b)

False

2.

True or False: Functions must be created and then run separately.

a)

True

b)

False

3.

Separating behaviors into different functions allows your code to follow your planning more easily (one function per behavior or even sub-behavior).

a)

True

b)

False

4.

True or False: Through the use of ____________, multiple related (but not identical) tasks can be handled with a single, intuitive function.

a)

semicolons

b)

curly brackets

c)

parameters

d)

()

5.

A function is created by “_______” it, and run by “calling” it.

a)

initializing

b)

declaring

c)

creating

d)

naming

6.

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.

a)

par

b)

int

c)

var

d)

void

7.

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.

a)

( )

b)

[ ]

c)

{curly braces}

d)

;

8.

Once you ________ your function, it acts like a new command in the language of ROBOTC. To run the function, simply “call” it by name

a)

declare

b)

initiate

c)

type

d)

decide

9.

________ are a way of passing information into a function, allowing the function to run its commands differently, depending on the values it is given.

a)

adjustables

b)

jingemalaries

c)

semicolons

d)

Parameters

10.

A parameter is declared in the same way that a variable is (type then name) inside the ______ following the function name

a)

{ }

b)

parentheses

c)

[ ]

d)

; and ;

11.

The parameter value behaves like a “_____”. Whatever value is provided for the parameter when the function is called will appear here.

a)

yellow card

b)

placeholder

c)

warning

d)

equal sign

12.

When the function is called, a _______ must be provided within the parentheses to take the place of the parameter inside the function.

a)

variable

b)

value

c)

adjustable

d)

letter

13.

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.

a)

var

b)

void

c)

int

d)

str

14.

Which of the following are true about functions

a)

Performs a specific task

b)

Groups related code for easy re-use

c)

May have a return value and/or parameter(s)

d)

Helps you to DRY up your code

15.

Which of the following is most similar to a function?

a)

Table of contents

b)

An instruction manual

c)

Class notes

d)

An outline for a paper

16.

What do variables and functions have in common?

a)

They are strings of commands

b)

They store instructions

c)

They replace a value

d)

They are coding shortcuts

17.

If you are coding a robot to sing a song, which part can be replaced by a function?

a)

chorus

b)

verse

c)

note

d)

rhymes

18.

When you declare a function you:

a)

Repeat it

b)

Run it

c)

Define it

d)

Combine it

19.

A statement in a function can be most closely compared to:

a)

A step in a recipe

b)

A line in a poem

c)

A brushstroke in a painting

d)

A piece of assembled furniture

20.

Programmers declare a function:

a)

The first time a function is called

b)

Every time a function is called

c)

At the beginning of the code

d)

At the end of the code

21.

In RobotC, which of these characters separates statements in a function?

a)

=

b)

{

c)

;

d)

[

22.

What does DRY stands for?

a)

Don't rely on yourself

b)

Don't repeat yourself

c)

Do rely on yourself

d)

Do repeat your functions