Midterm Flashcards
- Arrays in C++ must have a fixed size that is determined at the time of declaration.
- Elements in an array are stored in contiguous memory locations.
- It is possible to have arrays with a variable size that can be changed at runtime.
The Lie is #?
3
arrays must have a fixed size that is determined at the time of declaration and can not be changed later.
- The index of the first element in an array is always zero (0).
- The size of an array is stored as a member variable of the array.
- It is possible to initialize an array in C++ using a loop.
The lie is #?
2
Array doesn’t have any member variable to store the size of an array.
- It is possible to pass an entire array as an argument to a function.
- The elements of an array in C++ are stored in the order they are declared.
- It is possible to have a multidimensional array using only one pair of square brackets.
The lie is #?
3
To have a multidimensional array, multiple pairs of square brackets are required, one for each dimension.
- It is not possible to copy the values of one array to another array using the assignment operator.
- The for-each loop can be used to iterate through the elements of an array.
- C++ arrays have a built-in method to sort their elements in ascending or descending order.
The lie is #?
1
It is possible to copy the values of one array to another array using the assignment operator in C++ using (=).
- It is possible to create an array of pointers in C++.
- A single-dimensional array can be passed to a function as a reference.
- It is not possible to use the relational operators such as <, >, <=, >= to compare two arrays.
The lie is #?
3
it is possible to use the relational operators such as <, >, <=, >= to compare two arrays, as long as the arrays are of the same type and size.
What is a type of array that can store multiple arrays with the same data type?
Multidimensional
What is Function?
Subprogram that performs task.
What is function overloading in C++?
Using same function name multiple times.
What are function parameters in C++?
Using same function name multiple times.
What are function parameters in C++?
Information passed to a function.
What is function return type?
Data type of returned value.
Can a function return multiple values?
No, only one value returned
What are user-defined function types?
Custom data types.
A function that calls itself
Recursion
Can a function be declared inside main?
Yes
What is the purpose of function overloading in C++?
To use same name, different tasks.
What is a default argument in C++?
Predetermined value for parameter.
T/F Function overloading allows multiple functions with same name.
True
T/F Default arguments are mandatory in C++.
False
T/F Function prototypes are only used for functions with no return type.
False
T/F Inline functions can only be declared inside main.
False
T/F Reference parameters are alternative to values.
False
What is the purpose of function parameters?
To pass information to a function.
What is the purpose of default arguments?
To provide predetermined values for parameters.