CIS 330 Review
Which of the following is the inequality operator in C++?
!=
Which of the following is required in a program that uses the setprecision stream manipulator?
#include <iomanip>
Which of the following tells the compiler to merge the code contained in the iostream file with the current file's code?
#include <iostream>
Which of the following is a character literal constant?
'$'
int number = 0;cout << "Number: "; cin >> number; if (number <= 100)number = number * 2;elseif (number < 500)number = number * 3; else number = 100;//end if//end if If the user enters the number 1000, what value will be in the number variable after the selection structure code shown above is processed?
100
int number = 0;cout << "Number: "; cin >> number; if (number <= 100)number = number * 2;elseif (number < 500)number = number * 3; else number = 100;//end if//end if If the user enters the number 90, what value will be in the number variable after the code shown above is processed?
180
int number = 0;cout << "Number: "; cin >> number; if (number <= 100)number = number * 2;elseif (number < 500)number = number * 3; else number = 100;//end if//end if If the user enters the number 200, what value will be in the number variable after the code shown above is processed?
600
Which of the following is false?
A void function cannot receive any items of information when it is called.
A desk-check table should contain .
All the above
The first step in the problem-solving process is to .
Analyze the problem
if (id=='8') cout << "Janet";else if (id == '2' || id == '7') cout << " Mark";else if (id == '9') cout << "Jerry";else cout << "Sue" << endl;//end ifs What will display when the id variable contains the character 9? Use the above code.
Jerry
switch (id){case 8:cout << "Janet" << endl;break;case 2: case 7:cout << "Mark" << endl;break;case 9:cout << "Jerry" << endl;break;default:cout << "Sue" << endl;}//end switchWhat will the code display when the id variable contains the number 9? Use the code above.
Jerry
if (id=='8') cout << "Janet";else if (id == '2' || id == '7') cout << " Mark";else if (id == '9') cout << "Jerry";else cout << "Sue" << endl;//end ifs What will display when the id variable contains the character 2. Use the above code.
Mark
if (id=='8') cout << "Janet";else if (id == '2' || id == '7') cout << " Mark";else if (id == '9') cout << "Jerry";else cout << "Sue" << endl;//end ifsWhat will display when the id variable contains the character 7? Use the above code.
Mark
switch (id){case 8:cout << "Janet" << endl;break;case 2: case 7:cout << "Mark" << endl;break;case 9:cout << "Jerry" << endl;break;default:cout << "Sue" << endl;}//end switchWhat will the code display when the id variable contains the number 2? Use the code above.
Mark
if (id=='8') cout << "Janet";else if (id == '2' || id == '7') cout << " Mark";else if (id == '9') cout << "Jerry";else cout << "Sue" << endl;//end ifs What will display when the id variable contains the character 4? Use the above code.
Sue
switch (id){case 8:cout << "Janet" << endl;break;case 2: case 7:cout << "Mark" << endl;break;case 9:cout << "Jerry" << endl;break;default:cout << "Sue" << endl;}//end switchWhat will the code display when the id variable contains the number 4? Use the code above.
Sue
Which of the following is false?
The name of each actual argument should be identical to the name of its corresponding formal parameter.
Which of the following is false?
The names of the formal parameters in the function header must be identical to the names of the actual arguments in the function call.
Each memory location listed in a function header's parameterList is referred to as ________.
a formal parameter
The function header specifies ______.
all of the above
The declaration statement for a named constant requires _____________.
all the above
Which of the following is a valid name for a C++ variable?
amountSold
The num1 and num2 variables have the int data type and contain the numbers 13 and 5, respectively. The answer variable has the double data type. Which of the following statements will require an explicit type conversion to evaluate correctly?
answer = num1 + num1 / num2;
If an expression does not contain any parentheses, which of the following operators is performed first in the expression?
arithmetic
The calculation instructions in an algorithm should state .
both what is to be caluclated and how to calcuate it
Unless specified otherwise, variables in C++ are passed .
by value
Which of the following sends keyboard input to a variable named payRate?
cin >> payRate;
Which of the following declares a char named constant called TOP_GRADE?
const char TOP_GRADE = 'A';
Which of the following prompts the user to enter an hourly pay rate?
cout << "Pay rate per hour? ";
Which of the following statements advances the cursor to the next line on the computer screen?
cout << endl;
Which of the following tells the computer to display real numbers in fixed-point notation with no decimal places?
cout << fixed << setpercision(0);
Which of the following displays the contents of the quantity variable on the computer screen?
cout << quantity;
If you use a real number to initialize an int variable, the real number will be ____________ before it is stored in the variable.
demoted
Which of the following is the decision symbol in a flowchart?
diamond
Which of the following calls a void function named displayName, passing it no actual arguments?
displayName();
Which of the following correctly calls a void function named displayTotal, passing it an int variable named total?
displayTotal(total);
A program contains the statement tax=calcTax(sales);. The tax and sales variables have the double data type. Which of the following is a valid function header for the calcTax function?
double calcTax(double salesAmount)
Which of the following is a valid function header for a getFee function, which receives an integer first and a number with a decimal place second? The function returns a number with a decimal place.
double getFee(int base, double rate)
Which of the following is a valid function prototype for the getFee function, which receives an integer first and a number with a decimal place second? The function returns a number with a decimal place.
double getFee(int, double);
Which of the following declares a variable that can store a real number?
double totalDue = 0.0;
Most algorithms follow the format of _________.
entering the input items, then processing the input items, and then displaying, printing, or storing the output items
To determine whether an item is being passed by value or by reference, you must examine either the or the .
function header, function prototype
A void function named getInventory is passed four int variables named beginInv, sales, purchases, and endInv. the function's task is to calculate the ending inventory, using the beginning inventory, sales, and purchase amounts passed to the function. The function should store the result in the endInv variable. Which of the following statements calls the getInventory function?
getInventory(beginInv, sales, purchases, endInv);
Which of the following is a valid if clause? (The sales variable has the double data type.)
if (average > 70.5 && average < 80.5)
Which of the following conditions evaluates to true when the letter variable contains the letter Z in either uppercase or lowercase?
if (letter == 'Z' || letter == 'z')
Which of the following compares the contents of an int variable named quantity with the number 5?
if (quantity == 5)
A problem's ______________ will answer the question What information will the computer need to know to display, print, or store the output items?
input
Programmers refer to the items needed to reach a problem's goal as the .
input
Which of the following stores the letter T to a char variable named insured?
insured = 'T';
Which of the following declares a variable that can store an integer?
int quantity = 0;
Which of the following statements changes the contents of a char variable named letter to lowercase?
letter = tolower(letter);
Which of the following directs a function to return the contents of the stateTax variable to the statement that invoked it, which is contained in the main function?
none of the above
Which of the following is a valid comment in C++?
none of the above
Value-returning functions can return ________
one value only
A problem's ______________ will answer the question What does the user want to see displayed on the screen, printed on the printer, or stored in a file?
output
Programmers refer to the goal of solving a problem as the .
output
The short English statements that represent algorithm are called .
pseudocode
Which of the following is equivalent to the rate = rate / 100;statement?
rate /= 100;
A variable's indicates where in the program a variable can be used.
scope
A C++ statement must end with a ________________.
semicolon
The oval in a flowchart is called the symbol
start/stop
1/1 Which of the following explicitly converts the contents of an int variable named quantity to the double data type?
static_cast<double>(quantity);
The rules you must follow when using a programming language are called its .
sythax
The expression 4 * 3 < 6 + 7 && 7 < 6 + 9 evaluates to .
true
The int data type is one of the fundamental data types in C++.
true
Which of the following is a correct function prototype for a void function that requires no formal parameters? The function's name is displayName.
void displayName();
A void function named getEndBal is passed the values stored in two int variables. Which of the following function prototypes is correct for this function?
void getEndBal(int, int);
A void function named getInventory is passed four int variables named beginInv, sales, purchases, and endInv. the function's task is to calculate the ending inventory, using the beginning inventory, sales, and purchase amounts passed to the function. The function should store the result in the endInv variable. Which of the following function headers is correct?
void getInventory(int b, int s, int p, int &e)
A program contains a void function named getNewPrice. The function receives two doublevariables named oldPrice and newPrice. The function multiplies the contents of the oldPrice variable by 1.1 and then stores the result in the newPrice variable. Which of the following is the appropriate function prototype for this function?
void getNewPrice(double, double &);