1 CIS 205 Practice Test George Lamperti
2 1. A word that has a predefined meaning in a C++ program and cannot be used as a variable name is known as a _____________________. a. ID b. reserved word c. non-variable word d. word key
3 1. A word that has a predefined meaning in a C++ program and cannot be used as a variable name is known as a _____________________. a. ID b. reserved word c. non-variable word d. word key
4 2. Indicate if the following are input or output statements: a. cin >> x; b. cout << y; c. cin >> a >> b; d. cout << “hello”;
5 2. Indicate if the following are input or output statements: a. cin >> x;Input b. cout << y;Output c. cin >> a >> b; Input d. cout << “hello”; Output
6 3. Which of the following are valid variable names? a. temperature b. cost_of_living c. $deposit d. side2 e. weight_ f. percent%_raise
7 3. Which of the following are valid variable names? a. temperature b. cost_of_living c. $deposit d. side2 e. weight_ f. percent%_raise
8 4. Memory that loses its contents when the power is removed is ______________memory. a. hot b. empty c. volatile d. fixed
9 4. Memory that loses its contents when the power is removed is ______________memory. a. hot b. empty c. volatile d. fixed
10 5. A statement that identifies a variable name to a program is known as a _______________ statement. a. declaration b. static c. variable d. definite
11 5. A statement that identifies a variable name to a program is known as a _______________ statement. a. declaration b. static c. variable d. definite
12 6. When a function is called, the variables or values within the parenthesis are called _____________________. a. parameters b. entries c. arguments d. variables
13 6. When a function is called, the variables or values within the parenthesis are called _____________________. a. parameters b. entries c. arguments d. variables
14 7. The variables within the function parenthesis in the function heading are called _____________________. a. parameters b. entries c. arguments d. variables
15 7. The variables within the function parenthesis in the function heading are called _____________________. a. parameters b. entries c. arguments d. variables
16 8. When inputting characters into char variables, the << operation will skip over _____________________. a. periods b. slashes ( / ) c. numbers d. blanks (white spaces)
17 8. When inputting characters into char variables, the << operation will skip over _____________________. a. periods b. slashes ( / ) c. numbers d. blanks (white spaces)
18 9. Express each value in E-notation (C++ coding convention) a _______________ b. 576,000,000,000.0_______________
19 9. Express each value in E-notation (C++ coding convention) a __5.76e-6 ______ b. 576,000,000,000.0__5.76e11 ______
What values would be assigned to the int variable x in each case? a. x = ; b. x = 5 / 7.6; c. x = 7 / 5; d. x = 7.6 / 5.5;
What values would be assigned to the int variable x in each case? a. x = ; 13 b. x = 5 / 7.6; 0 c. x = 7 / 5; 1 d. x = 7.6 / 5.5; 1
The integer constant or variable within brackets used to reference a particular one-dimensional array cell is called the array __________________________. a. counter b. indicator c. index or subscript d. modifier
The integer constant or variable within brackets used to reference a particular one-dimensional array cell is called the array __________________________. a. counter b. indicator c. index or subscript d. modifier
Do array parameter declarations in a function need to use the & operator if the array is to be changed or modified? a. yes – arrays are never passed by reference b. no – arrays are automatically passed by reference
Do array parameter declarations in a function need to use the & operator if the array is to be changed or modified? a. yes – arrays are never passed by reference b. no – arrays are automatically passed by reference
Write a simple for loop segment to output the following array: Int values[20];
Write a simple for loop segment to output the following array: Int values[20]; for(n = 0; n < 20; n++) cout << values[n];
If an integer array is partially initialized, the unspecified cells will be set to _____________________. a. zero (0) b. blanks c. nulls d. none of the above
If an integer array is partially initialized, the unspecified cells will be set to _____________________. a. zero (0) b. blanks c. nulls d. none of the above
Write a simple for loop segment to allow the user to input new values in the array of question 13.
Write a simple for loop segment to allow the user to input new values in the array of question 13. for(n = 0; n < 20; n++) cin >> values[n];
A loop where the exact number of repeats or repetitions is not known is called an __________________ loop. a. undefined b. ill-defined c. indefinite d. counted
A loop where the exact number of repeats or repetitions is not known is called an __________________ loop. a. undefined b. ill-defined c. indefinite d. counted
Write the section of code that could be used to input and sum a list of exactly 25 values.
Write the section of code that could be used to input and sum a list of exactly 25 values. count = 0.0; sum = 0.0; while(count < 25.0) { cin >> value; sum = sum + value; count = count + 10; }
Write a section of code that could be used to output YES if the variable cost is greater than or output NO if cost is less than or equal to
Write a section of code that could be used to output YES if the variable cost is greater than or output NO if cost is less than or equal to if(cost > 100.0) cout << “YES”; else cout << “NO”;
If the user is to enter a sentinel value at the end of an indefinite list of vaues, the programmer would use an ____________________ loop. a. indefinite b. undefined c. counted d. ill-defined
If the user is to enter a sentinel value at the end of an indefinite list of vaues, the programmer would use an ____________________ loop. a. indefinite b. undefined c. counted d. ill-defined
If the user is to enter a sentinel value at the end of an indefinite list of values, the programmer would use an ____________________ loop. a. indefinite b. undefined c. counted d. ill-defined
Draw a symbolic diagram or flowchart of a program segment that could be used to output the message PASS or FAIL for a given test score. Assume 65 and above is a passing score
42 Score>=65? cout<<”PASS”cout<<”FAIL” TrueFalse Score>=65? cout<<“PASS”Cout<<“FAIL” True False
Which Boolean operator should be used in a condition to test if either variable a or variable b is true? _____________________. _____________________. a. && b. ! c. == d. ||
Which Boolean operator should be used in a condition to test if either variable a or variable b is true? _____________________. _____________________. a. && b. ! c. == d. ||
A good rule of thumb is always to place _____________________ around both choices of a two-choice if. a. [] b. () c. {} d. //
A good rule of thumb is always to place _____________________ around both choices of a two-choice if. a. [] b. () c. {} d. //
Which Boolean operator should be used in a condition to test if both variable a and variable b is true? a. && b. ! c. == d. ||
Which Boolean operator should be used in a condition to test if both variable a and variable b is true? a. && b. ! c. == d. ||
Consider the following for loop: for(n=0; n<10; n++) cout << “hello” << endl; How many different lines will the above loop produce? a. 9 lines b. 11 lines c. 10 lines d. 0 lines
Consider the following for loop: for(n=0; n<10; n++) cout << “hello” << endl; How many different lines will the above loop produce? a. 9 lines b. 11 lines c. 10 lines d. 0 lines
Rewrite the following definite loop using a for statement. Int count; Count = 0; While(count < 25) { cout << “count is “ << count << endl; count++;}
Rewrite the following definite loop using a for statement. Int count; Count = 0; While(count < 25) { cout << “count is “ << count << endl; count++;} for(int count = 0; count < 25; count++) cout << “count is “ << count << endl;
If a function does not return a value, with what type must the function be declared? __________________. __________________.
If a function does not return a value, with what type must the function be declared? void functions do not return a value void functions do not return a value
If SomeFuncA() calls or invokes SomeFuncB(), in what order should these two functions be defined? functions be defined? a. SomeFuncA() then SomeFuncB() b. SomeFuncB() then SomeFuncA() c. the order does not matter
If SomeFuncA() calls or invokes SomeFuncB(), in what order should these two functions be defined? functions be defined? a. SomeFuncA() then SomeFuncB() b. SomeFuncB() then SomeFuncA() c. the order does not matter
The following program is required to calculate the square root of a variable. What must be included for the library function sqrt() to be accessible? must be included for the library function sqrt() to be accessible? ______________________. ______________________. Void main() { float voltage; cin << voltage; cout << “root is: “ << sqrt(voltage);
The following program is required to calculate the square root of a variable. What must be included for the library function sqrt() to be accessible? must be included for the library function sqrt() to be accessible? #include #include Void main() { float voltage; cin << voltage; cout << “root is: “ << sqrt(voltage);
The >> extraction operator reads a character sequence into a string variable until a _____________ ______________ is detected. _____________ ______________ is detected. a. carriage return b. white space c. null operator d. number value
The >> extraction operator reads a character sequence into a string variable until a _____________ ______________ is detected. _____________ ______________ is detected. a. carriage return b. white space c. null operator d. number value
To test if a string variable contains a particular word, the ____________________ function can be used. a. find() b. islike() c. ismember() d. memberof()
To test if a string variable contains a particular word, the ____________________ function can be used. a. find() b. islike() c. ismember() d. memberof()
What is the initial value of a string variable that is not initialized? a. blank b. zero c. empty or null string d. whatever is in that piece of allocated memory
What is the initial value of a string variable that is not initialized? a. blank b. zero c. empty or null string d. whatever is in that piece of allocated memory
The ______________ variable type may be used to hold a sequence of values as opposed to a single value like int or float.
The String variable type may be used to hold a sequence of values as opposed to a single value like int or float.
The getline() function reads a character sequence into a string variable until the end of a ___________________ is reached. a. sentence b. executable line of code c. ; (semicolon) d. line
The getline() function reads a character sequence into a string variable until the end of a ___________________ is reached. a. sentence b. executable line of code c. ; (semicolon) d. line
69 End of Final Practice Test