Chapter 6 – User-Defined Functions (zyBooks)

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/39

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering key terms and example functions from zyBooks Chapter 6 on user-defined functions: basics, parameters, return values, modular development, arrays, and common lab exercises.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

40 Terms

1
New cards

Function

A named list of statements that can be invoked (called) from elsewhere in a program.

2
New cards

Function definition

The code that introduces a new function, starting with the keyword Function, the function’s name, parameters (if any), and ending with its statements.

3
New cards

Function call

An invocation of a function’s name followed by parentheses that causes the function’s statements to execute.

4
New cards

Main function

The entry point of a program; execution always begins with Main().

5
New cards

Local variable

A variable declared inside a function and accessible only within that function.

6
New cards

Parameter

An input listed in a function definition that receives a value when the function is called.

7
New cards

Argument

A value or expression supplied to a function’s parameter during a call.

8
New cards

Return variable

A variable in a function that holds the single value the function will return.

9
New cards

Return statement

A statement (often the keyword return in many languages) that explicitly sends a value back to the caller and exits the function.

10
New cards

Void / returns nothing

Indicates that a function does not return a value.

11
New cards

Position-based parameter matching

Arguments are assigned to parameters based on their left-to-right order in the call.

12
New cards

Expression context

The ability to use a function call inside an expression because it evaluates to its returned value.

13
New cards

Function with no parameters

A function whose parentheses are empty; it is still called with ().

14
New cards

Function with multiple parameters

A function that lists two or more parameters, each receiving a corresponding argument.

15
New cards

Mathematical function

User-defined function created to perform a numeric calculation and return a numeric result (e.g., CircleArea).

16
New cards

Branch inside a function

Use of if-else statements within a function’s body.

17
New cards

Loop inside a function

Use of while or for loops within a function’s body.

18
New cards

Functions calling functions

When the statements of one user-defined function invoke another function.

19
New cards

Modular development

Dividing a program into separate, independently testable functions or modules.

20
New cards

Incremental development

Writing and testing small portions of code repeatedly to build a program step-by-step.

21
New cards

Function stub

A temporary, incomplete function definition used during early development to allow compilation and testing.

22
New cards

Readability benefit

Using functions keeps Main() short and makes program logic easier to understand.

23
New cards

Avoiding redundancy

Writing a computation once in a function and reusing it through calls instead of duplicating code.

24
New cards

Guideline: ≤ 20 statements

Typical recommendation for the maximum size of a beginner’s function to maintain clarity.

25
New cards

Array parameter

A parameter declared with the word array, allowing an entire array to be passed to a function.

26
New cards

numList.size

Property used inside a Coral function to obtain the length of an array parameter.

27
New cards

CountValsOverThreshold

Example function that returns how many elements in an array exceed a given threshold.

28
New cards

CircleArea example

Demonstrates computing area from diameter inside a function and reusing it multiple times.

29
New cards

PizzaCalories example

Shows one function (PizzaCalories) calling another (CircleArea) to calculate total calories.

30
New cards

AbsoluteValue

Typical helper function used to illustrate code reuse and avoidance of repetitive statements.

31
New cards

RaiseToPower

Built-in function example showing that functions can be nested inside expressions.

32
New cards

SeedRandomNumbers(2)

Call that seeds Coral’s random number generator for reproducible results (e.g., in PrintCoinFlips).

33
New cards

MilesToLaps

Example function converting miles walked to track laps (1 lap = 0.25 miles).

34
New cards

MaxMagnitude

User-defined function that returns the value with the greatest magnitude among two integers.

35
New cards

DrivingCost

Function that computes fuel cost from miles driven, miles per gallon, and dollars per gallon.

36
New cards

StepsToMiles

Function that converts pedometer steps to miles (2,000 steps = 1 mile).

37
New cards

SecondsToJiffies

Function that converts seconds to jiffies, where 1 jiffy = 0.01 seconds.

38
New cards

OutputLeapYear

Function that prints whether a given year satisfies leap-year rules (divisible by 4, and by 400 if century).

39
New cards

IntegerToBinary

Function that outputs the binary representation of a positive integer in reverse order.

40
New cards

getMinimumInt

Function returning the smallest element in an integer array, used for normalizing data.