CC 203 Midterms Review: Arrays and Strings

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/63

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.

64 Terms

1
New cards

Simple Data Type

variables of this type can store only one value at a time

2
New cards

Structured Data Type

a data type in which each data item is a collection of other data items

3
New cards

Array

a collection of a fixed number of components

4
New cards

One Dimensional Arrays

components are arranged in list form

5
New cards

Syntax for declaring one dimensional arrays

dataType arrayName [intExp];

6
New cards

intExp

any constant expression that evaluates into a positive integer

7
New cards

General Syntax for accessing array elements

arrayName[indexExp]

8
New cards

indexExp

called the index (an integer with a nonnegative integer value)

9
New cards

Basic Operations of a one-dimensional array

Initializing, Inputting Data, Outputting data stored in an array, Finishing the largest and or smallest element

10
New cards

Index of an array

is in bounds if the index is >= 0 and <= ARRAY_SIZE -1

11
New cards

Out of bounds index

the index is out of bounds if it does not meet the criteria of being in bounds

12
New cards

Array Initialization during Declaration

Arrays can be initialized during declaration with values placed between curly braces

13
New cards

Partial Initialization of Arrays during Declaration

Size determined by the number of initial values in braces

14
New cards

Aggregate Operation

any operation that manipulates the entire array as a single unit, not allowed on arrays in C++

15
New cards

Arrays as Parameters to Functions

Arrays are passed by reference only

16
New cards

Constant Arrays as Formal Parameters

They can prevent a function from changing the actual parameter when passed by reference

17
New cards

Base Address of an Array

address (memory location) of the first array component

18
New cards

Functions cannot return a value of the type Array

C++ does not allow functions to return a value of type array

19
New cards

Integral Data Types and Array Indices

C++ allows any integral type to be used as an array index

20
New cards

Sequential Search

Searching a list for a given item, starting from the first array element

21
New cards

Selection Sort

rearrange the list by selecting an element and moving it to its proper position

22
New cards

Character Array

an array whose components are of type char

23
New cards

C-Strings

null-terminated ('\0') character arrays

24
New cards

Example of C-Strings

'A' is the character A; "A" is the c-string A; "A" represents two characters: 'A' and '\0'

25
New cards

Maximum string length in C-Strings

the largest string it can store is 15 characters if it has 16 components

26
New cards

Omitting size of an array during initialization

Size of an array can be omitted if the array is initialized during declaration

27
New cards

strcpy

Function used to copy a string.

28
New cards

strcmp

Function used to compare two strings.

29
New cards

strlen

Function used to determine the length of a string.

30
New cards

C-Strings

Character arrays that are null-terminated.

31
New cards

ASCII character set comparison

Character strings are compared using the ASCII values, e.g., 'Air' < 'Boat'.

32
New cards

cin >> name

Reads the next input c-string into the variable name.

33
New cards

cin.get(str, m+1)

Reads the next m characters into str, excluding the newline character.

34
New cards

cout << name

Outputs the content of name to the screen.

35
New cards

Null character

Character that indicates the end of a c-string.

36
New cards

c_str function

Converts a string variable to a c-string.

37
New cards

Parallel arrays

Two or more arrays that hold related information.

38
New cards

Two-dimensional arrays

Collections of components arranged in rows and columns.

<p>Collections of components arranged in rows and columns.</p>
39
New cards

Declaration syntax for two-dimensional arrays

dataType arrayName [intExp1][intExp2].

40
New cards

Accessing components in a two-dimensional array

arrayName[indexExp1][indexExp2] where indexExp1 and indexExp2 specify row and column.

41
New cards

Sales[5][3]

Example of accessing a component in a two-dimensional array.

42
New cards

Two-dimensional array initialization

Can be initialized at declaration with elements enclosed in braces.

43
New cards

Unspecified elements in number arrays

Are set to 0 when not explicitly initialized.

44
New cards

Two-dimensional array

A structured data type with a fixed number of components of the same type, arranged in a table form.

45
New cards

Row processing

Processing a two-dimensional array one row at a time.

46
New cards

Column processing

Processing a two-dimensional array one column at a time.

47
New cards

One-dimensional array

An array where elements are arranged in the form of a list.

48
New cards

Base address

The address of the first array component.

49
New cards

Passing two-dimensional arrays

Two-dimensional arrays are passed by reference as parameters to a function.

50
New cards

Row order storage

Two-dimensional arrays are stored in row order.

51
New cards

Array of strings

A collection of strings that can be manipulated using either the string data type or character arrays (c-strings).

52
New cards

Declaration of array of strings

To declare an array of 100 components of type string: string line[100].

53
New cards

N-dimensional array

A collection of a fixed number of elements arranged in n dimensions (n >= 2).

54
New cards

Declaration syntax for multidimensional arrays

dataType arrayName[intExp1][intExp2]... [intExp];

55
New cards

Accessing a component

To access a component: arrayName[index1][index2]...[indexEspn].

56
New cards

Array index

An expression that evaluates to a nonnegative integer, must always be less than the size of the array.

57
New cards

Function return for arrays

A function cannot return an array type value.

58
New cards

C-strings

C-strings are null terminated and are stored in character arrays.

59
New cards

Common c-string functions

Commonly used c-string manipulation functions include: strcpy, strcmp, strlen.

60
New cards

Parallel arrays

Arrays used to hold related information.

61
New cards

Accessing elements in two-dimensional arrays

To access an element, you need a pair of indices: one for row position, one for column position.

62
New cards

Sum by row

Calculating the total of each row in a two-dimensional array.

<p>Calculating the total of each row in a two-dimensional array.</p>
63
New cards

Sum of column

Calculating the total of each column in a two-dimensional array.

<p>Calculating the total of each column in a two-dimensional array.</p>
64
New cards

Largest element in each row and column

Finding the largest element for every row and every column in a two-dimensional array.

<p>Finding the largest element for every row and every column in a two-dimensional array.</p>