Quiz & Exam Review (#2) - previous deck disappeared Flashcards
Which of the following casting expressions is recommended by the ANSI standard?
- intVar = (int)doubleVar;
- intVar = int(doubleVar);
- intVar = static_cast(doubleVar);
- intVar = (double)doubleVar;
intVar = static_cast(doubleVar);
The values in an enumerated data type are actually stored as integers.
- True
- False
True
What is the correct order of precedence of the logical (Boolean) operators?
- ||, !, &&
- &&, ||, !
- !, &&, ||
- &&, !, ||
!, &&, ||
Opening a file is an operation that can fail, so you should test for that possibility.
- True
- False
True
The rand() function automatically generates a different sequence of random values each time you run your program.
True
False
False
Which two of the following can be used to make subsequent console output begin on a new line?
endl
cin
‘\t’
‘\n’
endl
and
‘\n’
What order do the parts of a function header appear in?
- name, parameter list, return type
- name, return type, parameter list
- return type, name, parameter list
- parameter list, name, return type
return type, name, parameter list
A vector’s “size” and “capacity” are two different things.
- True
- False
True
include does what?
- prints “iostream”
- replaces occurences of “include” with “iostream”
- resets the cursor
- gives a program access to a library of input/output functions
gives a program access to a library of input/output functions
RAM is a type of secondary storage.
- True
- False
False
Which two of the following make up a CPU?
RAM
control unit
ROM
ALU
Control Unit
and
ALU
A variable of which type is used to hold a true or false value?
- int
- char
- bool
- double
bool
A set of well-defined steps for performing a task or solving a problem is a(n)
- input device
- statement
- compiler
- algorithm
algorithm
What will be the output of the following line of code?
std::cout << 5 / 4 << std::endl;
- 1.25
- 0
- 1
- 0.8
1
Which of the following statements is true?
- A local variable can have the same name as a global variable, but then it cannot be accessed, because when you use that name, it will refer to the global variable instead of the local variable.
- A local variable cannot have the same name as a global variable.
- A variable declared at the function level cannot have the same name as one of that function’s parameters, because they would have the same scope.
A variable declared at the function level cannot have the same name as one of that function’s parameters, because they would have the same scope.
By default classes are passed to a function by reference.
- True
- False
False
Which of the following is a valid vector declaration?
- double nums;
- vector(10);
- string words[10];
- vector data(10);
vector data(10);
While loops are specifically designed for the case when you know at the beginning of the loop how many times it should repeat.
- True
- False
False
If a variable is passed as a parameter to a function, the name used for that parameter within the function must match that of the variable.
- True
- False
False