CSCI 111 pt.2
Suppose that ch1, ch2, and ch3 are variables of the type char. The input is: A B C What is the value of ch3 after the following statements execute? cin.get(ch1); cin.get(ch2); cin.get(ch3);
'B'
Suppose that ch1, ch2, and ch3 are variables of the type char. The input is: A B C Choose the value of ch3 after the following statement executes: cin >> ch1 >> ch2 >> ch3;
'C'
Suppose that x is an int variable. Which of the following expressions always evaluates to true?
(x > 0) || ( x <= 0)
C++ comes with a wealth of functions, called ____________________ functions, that are written by other programmers.
/predefined/, /pre defined/, /pre-defined/
The statement: return 8, 10; returns the value ____.
10
Which of the following expressions correctly determines that x is greater than 10 and less than 20?
10 < x && x < 20
The operators !, &&, and || are called relational operators.
false
When the computer is turned off, everything in secondary memory is lost.
false
A data type is called ____________________ if the variable or named constant of that type can store only one value at a time.
simple
In a(n) ____________________ data type, each data item is a collection of other data items.
structured
The smallest individual unit of a program written in any language is called a(n) ____________________.
token
If a C++ arithmetic expression has no parentheses, operators are evaluated from left to right.
true
The maximum number of significant digits in values of the double type is 15.
true
If a function needs to return more than one value, as a rule of good programming style, you should change it to a(n) ____________________ function and use the appropriate reference parameters to return the values.
void
Aggregate input/output operations are allowed on a struct variable.
false
If the formal parameter list of a function is empty, the parentheses after the function name are not needed.
false
In C++, the member access operator arrow is >>.
false
In structs, you access a component by using the struct name together with the relative position of the component.
false
What is the output of the following statements? cout << "123456789012345678901234567890" << endlcout << setfill('#') << setw(10) << "Mickey"<< setfill(' ') << setw(10) << "Donald" << setfill('*') << setw(10) << "Goofy" << endl;
123456789012345678901234567890 ####Mickey Donald*****Goofy
What is the next Fibonacci number in the following sequence? 1, 1, 2, 3, 5, 8, 13, 21, ...
34
What is the value of x after the following statements execute? int x = 25; int *p; p = &x; *p = 46;
46
What is the value of alpha[2] after the following code executes? int alpha[5];int j;for (j = 0; j < 5; j++)alpha[j] = 2 * j + 1;
5
Consider the following statement: double alpha[10][5];. The number of components of alpha is ____.
50
The statement int *p; is equivalent to int * p;, which is also equivalent to the statement ____________________.
6
The output of the statement: cout << pow(2.0, pow(3.0, 1.0)) << endl; is ____.
8.0
A variable or expression listed in a call to a function is called a(n) ____.
actual parameter
Suppose that ch1 and ch2 are char variables, and alpha is an int variable. The input is: A 18 What are the values after the following statement executes? cin.get(ch1); cin.get(ch2); cin >> alpha;
ch1 = 'A', ch2 = ' ', alpha = 18
In C++, the mechanism that allows you to combine data and operations on the data into a single unit is called a(n) ____________________.
class
The word ____________________ is used before the array declaration in a function heading to prevent the function from modifying the array.
const
To generate a random number, you can use the function rand from the header file ____________________.
cstdlib
Which of the following loops does not have an entry condition?
do...while loop
Which of the following loops is guaranteed to execute at least once?
do...while loop
Given the statement double *p;, the statement p++; will increment the value of p by ____ byte(s).
eight
Once an input stream enters a(n) ____________________ state, all subsequent input statements associated with that input stream are ignored, and the computer continues to execute the program, which produces erroneous results.
fail
The basic commands that a computer performs are ____, and performance of arithmetic and logical operations.
input, output, storage
The declaration int a, b, c; is equivalent to which of the following?
int a,b,c;
Which of the following function prototypes is valid?
int funcExp(int x, float v);
The memory space for a(n) ____________________ data value is 4 bytes.
int.
What does <= mean?
less than or equal to
Consider the following function prototype: int seqSearch(const listType& list, int searchItem); The formal parameter _____ cannot modify the corresponding actual parameter.
list
Consider the following struct definition: const int ARRAY_SIZE = 1000; struct listType { int listElem[ARRAY_SIZE]; int listLength; }; The statement that declares intList to be a struct variable of type listType is ____________________.
listType intList;
In C++, the dot is an operator called the ____ operator.
member access
A(n) ____ consists of data and the operations on those data.
object
The function ____________________ returns the next character in the input stream; it does not remove the character from the input stream.
peek
Consider the following statements:struct personalInfo{string name;int age;double height;double weight;};struct commonInfo{string name;int age;}; personalInfo person1, person2;commonInfo person3, person4;
person2 = person1;
In a C++ program, statements that begin with the symbol # are called ____________________ directives.
preprocessor
Stream variables (for example, ifstream and ofstream) should be passed by ____________________ to a function.
reference
Putting a semicolon after the parentheses following the expression in an if statement (that is, before the statement) is a(n) ____________________ error.
semantic
The term ____________________ describes a process in which the computer evaluates a logical expression from left to right and stops as soon as the value of the expression is known.
short circuit evaluation