Functions Flashcards

1
Q

What is a function in programming?

A

A module that returns a value back after performing a specific task.

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

Can the value returned by a function be used like other values?

A

Yes, it can be used like any other value.

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

What is a library function?

A

A function built into the programming language, usually found in the standard library.

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

What three things must you know about a library function?

A

Its purpose, the arguments to pass, and the data it returns.

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

What are you essentially creating when you write your own function?

A

A module.

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

What is the role of a function’s header?

A

It specifies the return value data type, the function name, and parameter variables.

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

What does the body of a function contain?

A

One or more statements that are executed after a function call.

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

What is the role of the return statement in a function?

A

It returns a value to the part of the program that called the function.

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

What is a parameter variable in a function header?

A

A variable that receives a value when the function is called.

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

Where is the first line of a function definition located?

A

In the function header.

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

What is used to represent the starting terminal of a function in a flowchart?

A

The function’s name and parameters.

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

Why are flowcharts helpful when designing functions?

A

They visually represent the sequence and parameters of the function.

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

What can a return statement return, aside from plain values?

A

Expressions.

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

Why is the ability to return expressions useful in a function?

A

It allows flexibility in computations before returning a result.

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

What does IPO stand for in IPO charts?

A

Input, Processing, and Output.

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

How does an IPO chart assist with function development?

A

It organizes the input, processing, and output components of a function.

17
Q

What does the function’s return value depend on?

A

The return statement’s expression or value.

18
Q

How can a function enhance modularity in programming?

A

By encapsulating specific tasks into reusable modules.

19
Q

What is a key difference between library functions and custom-written functions?

A

Library functions are predefined, while custom-written functions are user-defined.

20
Q

What is required to call a function?

A

Its name and the correct number/type of arguments (if any).