Unit 1c – Arrays & Functions

0.0(0)
studied byStudied by 1 person
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/18

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

19 Terms

1
New cards

What is an array?

Fixed-size, contiguous, ordered collection of same-type variables accessed by index

2
New cards

Why use arrays?

When you need to revisit data multiple times.

3
New cards

What happens if you access an invalid index?

Undefined behavior (C++ does not check bounds)

4
New cards

How does array initialization behave?

No initializer → garbage values.

Fewer initializers → rest filled with zeros.

int arr[] = {1,2,3}; → compiler infers size.

5
New cards

What is decomposition?

Breaking a program into smaller functions.

6
New cards

What is abstraction?

Hiding details, showing only “what it does.”

7
New cards

What is a function prototype?

Declares function’s return type and parameters so it can be called before definition.

Example: double area(double, double);

8
New cards

What is function overloading?

Same function name, different parameter list (number or type).

9
New cards

Procedural vs OOP?

Procedural: function = unit of organization.

OOP: class/object = unit of organization.

10
New cards

What is an array look-up table?

Precomputed results stored in an array, accessed by index.

11
New cards

What is a character array (C-string)?

Array of chars ending with \0. Example: char str[] = "Hi";

12
New cards

Why are arrays passed by reference?

Passing whole arrays by value would copy too much data. Instead, only the starting pointer is passed.

13
New cards

What are void functions?

Functions with no return value.

14
New cards

What is pass-by-value vs. pass-by-reference?

Value = copy passed (safe, but doesn’t affect caller).

Reference = original passed (function can change caller’s variable).

15
New cards

What are common C-string library functions?

strlen(s) → length

*strcpy(dest, src) → copy string

*strncpy(dest, src, n) → safe copy

strcmp(s1, s2) → compare (0 = equal)

strcat(char *dest, const char *src) -> Adds str to end of dest

strchr(const char *str, char c) -> Finds first occurrence of c & returns ptr

16
New cards

User Defined Functions

"Declare" your function by placing the prototype (signature) at the top of your code

"Define" the function

"Call" the function

17
New cards

Formal vs Actual parameters:

Placeholder names that will be used internally to the function to refer to the values passed

Actual values to be passed

18
New cards

Memory organization:

Code usually sits at lower addresses

Global variables/data somewhere after code

Heap: Area of memory that can be allocated and de-allocated during program execution

Stack (our focus): Memory for all information related to each running instance of a function like arguments, local variables, return link

19
New cards

Stacks:

Each time a function is called, the computer allocates memory for that function on the top of the stack and creates a link for where to return

When a function returns/ends, that memory is deallocated

Explore top flashcards

respiratory system
Updated 695d ago
flashcards Flashcards (22)
Exam 2 For Dorth
Updated 229d ago
flashcards Flashcards (110)
The Immune System
Updated 324d ago
flashcards Flashcards (35)
Biology Unit 7
Updated 908d ago
flashcards Flashcards (210)
religion final
Updated 887d ago
flashcards Flashcards (29)
respiratory system
Updated 695d ago
flashcards Flashcards (22)
Exam 2 For Dorth
Updated 229d ago
flashcards Flashcards (110)
The Immune System
Updated 324d ago
flashcards Flashcards (35)
Biology Unit 7
Updated 908d ago
flashcards Flashcards (210)
religion final
Updated 887d ago
flashcards Flashcards (29)