User Defined Functions Flashcards

(25 cards)

1
Q

What is a function?

A

A named list of statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a function call?

A

invoking the function’s name, causing the statement to execute.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a local variable?

A

A variable declared within the function. It can only be used within that function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a parameter?

A

Function input specified within a function call.
For example: PrintPizzaArea(12), (12) in the parameter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an argument?

A

A value provided by the parameter during a function call.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

During arguments, should function calls have words inside the parentheses?

A

No.
Bad Example: numVal(integer 23, 2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can a function return one value?

A

Assigning a return variable with a return value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Can a function return more than one variable?

A

No, it can only return one.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

If a function that does not return a value cannot be used in an expression. Instead use?

A

outputData (x, y)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The variable goes on which side of a statement?

A

The left
Example of a variable x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What side of a statement does an expression go on?

A

The right
Example of an expression numsVal + 1 or squareroot (49.0)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is modular development?

A

Separating a program into segments, testing them individually, and later combining all parts together into a single program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is incremental development?

A

writing a portion of a program, testing it, then writing a bit more, testing, rinse and repeat.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a function stub?

A

A function whose statement(s) are yet to be written.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to prevent redundant statements?

A

By writing functions, they can be called from multiple places within the program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How to easily identify a function call?

A

statement has function name quickly followed by parentheses
Example: functionName( )

17
Q

How to identify a method function?

A

It uses a ( . ) dot
Example: name.upper ( )

18
Q

How to identify a user-defined function?

A

It does not use a ( . ) dot
Example: attack ( )

19
Q

When writing code in coral how does a function start?

A

With the word function followed by the function’s name.

20
Q

How is a function definition setup?

A

the word “function.”
the function’s name
function parameters in parentheses (use commas if more than one)
Then the return indicator.

21
Q

What goes inside the parentheses for a function definition?

A

parameter type followed by the parameter name.
Examples: (float num1) or (integer userAge)

22
Q

Can a parameter contain an expression inside it?

A

No
Example: (integer UserName + 5 )

23
Q

When a program first executes, what is the first function “called”?

A

Main() is always the first function called, to start the programs execution.

24
Q

If you want a function to return something what must the function definition have at the end?

A

The word “returns” the variable type and the name.
Example: returns float numVals

25
How many items can a function return?
Only one