Computer Programming Final
____ is a valid char value. "A" "-129" 129 'A'
'A'
Suppose that ch1, ch2, and ch3 are variables of the type char and the input is: A B C Choose the value of ch3 after the following statement executes: cin >> ch1 >> ch2 >> ch3; 'A' 'B' '\n' 'C'
'C'
The expression static_cast<int>(6.9) + static_cast<int>(7.9) evaluates to ____.
13
The length of the string "computer science" is ____.
16
Suppose that count is an int variable and count = 1. After the statement count++; executes, the value of count is ____.
2
The value of the expression 17 % 7 is ____.
3
The value of the expression 33/10, assuming both values are integral data types, is ____.
3
Suppose that alpha, beta, and gamma are int variables and the input is: 100 110 120 200 210 220 300 310 320 What is the value of gamma after the following statements execute? cin >> alpha; cin.ignore(100, '\n'); cin >> beta; cin.ignore(100,'\n'); cin >> gamma;
300
____ is a valid int value. -32.00 46,259 46259 462.59
46259
The expression static_cast<int>(9.9) evaluates to ____.
9
Which example illustrates how a class can be used as an abstraction?
A programmer creates a class to handle a recognized pattern of repetitive social media login credential items.
Suppose that alpha and beta are int variables. The statement alpha = beta--; is equivalent to the statement(s) ____. A. alpha = beta; beta = beta - 1; B. beta = beta - 1; alpha = beta; C. alpha = 1 - beta; D. alpha = beta - 1;
A. alpha = beta; beta = beta - 1;
Suppose that x and y are int variables. Which of the following is a valid input statement? A. cin >> x >> y; B. cout << x << y; C. cin >> x >> cin >> y; D. cin << x << y;
A. cin >> x >> y;
Suppose that x is an int variable, y is a double variable, z is an int variable, and the input is: 15 76.3 14 Choose the values after the following statement executes: cin >> x >> y >> z; A. x = 15, y = 76.3, z = 14 B. x = 15, y = 76, z = 14 C. x = 15, y = 76, z = 0 D. x = 15.0, y = 76.3, z = 14.0
A. x = 15, y = 76.3, z = 14
Which example illustrates how abstraction can help identify variables?
Abstraction can be used in pattern recognition to identify possible variables.
What statement describes how dependencies and cohesion relate to decomposition?
An effective breakdown minimizes dependencies and maximizes cohesion among the various parts.
____ programs perform a specific task.
Application
Suppose that alpha and beta are int variables. The statement alpha = ++beta; is equivalent to the statement(s) ____. A. alpha = alpha + beta; B. beta = beta + 1; alpha = beta; C. alpha = beta; beta = beta + 1; D. alpha = beta + 1;
B. beta = beta + 1; alpha = beta;
Suppose that x is an int variable, y is a double variable and ch is a char variable and the input is:15A 73.2Choose the values after the following statement executes: cin >> x >> ch >> y; A. x = 15, ch = 'A', y = 73.0 B. x = 15, ch = 'A', y = 73.2 C. This statement results in an error because there is no space between 15 and A. D. x = 15, ch = 'a', y = 73.0
B. x = 15, ch = 'A', y = 73.2
Why are computer scientists interested in algorithm efficiency?
Because efficient algorithms tend to produce computer programs that in turn operate efficiently, quickly, and reliably.
The programming language C++ evolved from ____.
C
Choose the output of the following C++ statement: cout << "Sunny " << '\n' << "Day " << endl; A. Sunny \nDay B. Sunny \nDay endl C. Sunny Day D. Sunny \n Day
C. Sunny Day
Suppose that alpha and beta are int variables. The statement alpha = beta++; is equivalent to the statement(s) ____. A. alpha = 1 + beta; B. alpha = alpha + beta; C. alpha = beta; beta = beta + 1; D. beta = beta + 1; alpha = beta;
C. alpha = beta; beta = beta + 1;
Suppose that alpha and beta are int variables. The statement alpha = --beta; is equivalent to the statement(s) ____. A. alpha = beta; beta = beta - 1; B. alpha = 1 - beta; C. beta = beta - 1; alpha = beta; D. alpha = beta - 1;
C. beta = beta - 1; alpha = beta;
The declaration int a, b, c; is equivalent to which of the following? A. int abc; B. int a b c; C. int a,b,c; D. inta , b, c;
C. int a,b,c;
Suppose that x and y are int variables, z is a double variable, and the input is: 28 32.6 12 Choose the values of x, y, and z after the following statement executes: cin >> x >> y >> z; A. x = 28, y = 32, z = 12.0 B. x = 28, y = 12, z = 32.6 C. x = 28, y = 32, z = 0.6 D. .x = 28, y = 12, z = 0.6
C. x = 28, y = 32, z = 0.6
The ____ is the brain of the computer and the single most expensive piece of hardware in your personal computer.
CPU
In a C++ program, one and two are double variables and input values are 10.5 and 30.6. After the statement cin >> one >> two; executes, ____. A. one = 10.5, two = 10.5 B. one = 11, two = 31 C. one = 30.6, two = 30.6 D. one = 10.5, two = 30.6
D. one = 10.5, two = 30.6
____ represent information with a sequence of 0s and 1s.
Digital signals
A comma is also called a statement terminator.
False
A mixed arithmetic expression contains all operands of the same type.
False
An operator that has only one operand is called a unique operator.
False
C++ programs have always been portable from one compiler to another.
False
If input failure occurs in a C++ program, the program terminates immediately and displays an error message.
False
In C++, reserved words are the same as predefined identifiers.
False
In the statement cin >> x;, x can be a variable or an expression.
False
The device that stores information permanently (unless the device becomes unusable or you change the information by rewriting it) is called primary storage.
False
The devices that feed data and programs into computers are called output devices.
False
The escape sequence \r moves the insertion point to the beginning of the next line.
False
The following statements will result in input failure if the input values are not on a separate line. (Assume that x and y are int variables.) cin >> x; cin >> y;
False
When the computer is turned off, everything in secondary memory is lost.
False
When you compile your program, the compiler identifies the logic errors and suggests how to correct them.
False
Consider the following code. // Insertion Point 1 using namespace std; const float PI = 3.14; int main(){ // Insertion Point 2 float r = 2.0; float area; area = PI * r * r; cout << "Area = " << area << endl; return 0;} // Insertion Point 3 In this code, where does the include statement belong?
Insertion Point 1
Why is decomposition an important tool for computer scientists?
It creates algorithm designs with more manageable pieces, leading to programs that are more efficient and maintainable.
Which statement best describes a computer program?
It is a set of instructions that performs a specific task when executed by a digital device.
Which statement describes how the black box concept is an implementation of abstraction?
It produces an output while hiding the inner workings of a process.
Which statement describes why abstraction is an important computer science concept?
It provides a means to hide implementation details from the user to simplify subsequent development and promotes software reuse.
____ are executable statements that inform the user what to do.
Prompt lines
What characteristic best applies to an effective algorithm?
The algorithm produces one or more outputs.
Which example leads to an algorithm design used for an everyday technology application?
The payment process at an online store
Suppose that x and y are int variables, ch is a char variable, and the input is:4 2 A 12Choose the values of x, y, and ch after the following statement executes:cin >> x >> ch >> y; x = 4, ch = 2, y = 12 x = 4, ch = ' ', y = 2 x = 4, ch = A, y = 12 This statement results in input failure
This statement results in input failure
If a C++ arithmetic expression has no parentheses, operators are evaluated from left to right.
True
Suppose a = 5. After the execution of the statement ++a; the value of a is 6.
True
Suppose we declare a variable sum as an int. The statement "sum += 7;" is equivalent to the statement "sum = sum + 7;".
True
The basic commands that a computer performs are input (get data), output (display result), storage, and performance of arithmetic and logical operations.
True
The maximum number of significant digits in values of the double type is 15.
True
To develop a program to solve a problem, you start by analyzing the problem.
True
You can use the function getline to read a string containing blanks.
True
____ consists of 65,536 characters.
Unicode
Suppose that ch1 and ch2 are char variables and the input is: WXYZ What is the value of ch2 after the following statements execute?cin.get(ch1); cin.putback(ch1); cin >> ch2;
W
Suppose that ch1 and ch2 are char variables and the input is: WXYZ What is the value of ch2 after the following statements execute? cin >> ch1; ch2 = cin.peek(); cin >> ch2;
X
Which of the following is the newline character? \l \n \b \r
\n
Which term refers to a technique that hides details, simplifies complexity, and substitutes a generalization for something specific?
abstraction
A step-by-step problem-solving process in which a solution is arrived at in a finite amount of time is called a(n) ____.
algorithm
Which term refers to a series of steps for solving a problem or carrying out a task?
algorithm
Which idea represents an example of a repetitive pattern?
allowing three password entry attempts before locking a user out of an online account
Suppose that alpha is an int variable and ch is a char variable and the input is: 17 A What are the values after the following statements execute? cin >> alpha; cin >> ch; alpha = 1, ch = 7 alpha = 17, ch = ' ' alpha = 17, ch = 'A' alpha = 17, ch = 'a'
alpha = 17, ch = 'A'
Suppose that alpha and beta are int variables and alpha = 5 and beta = 10. After the statement alpha *= beta; executes, ____. alpha = 50 alpha = 50.0 alpha = 5 alpha = 10
alpha = 50
The digit 0 or 1 is called a binary digit, or ____.
bit
Which phase describes an example of functional decomposition?
breaking down a two-factor authentication module into smaller actions, processes, or steps
A sequence of eight bits is called a ____.
byte
Which of the following is a reserved word in C++? CHAR character Char char
char
A program called a(n) ____ translates instructions written in high-level languages into machine code.
compiler
What concept refers to a set of techniques designed to formulate problems and their solutions so that a programmer can select efficient algorithms?
computational thinking
What term refers to the process of dividing an extensive app into smaller parts?
decomposition
Which phrase describes an example of structural decomposition?
dividing a mobile banking app into hierarchical structural units
An example of a floating point data type is ____. double short int char
double
The memory allocated for a float value is ____ bytes.
four
The term GB refers to ____.
gigabyte
The devices that feed data and programs into computers are called ____ devices.
input
The basic commands that a computer performs are ____, and performance of arithmetic and logical operations.
input, output, storage
Manipulators without parameters are part of the ____ header file.
iostream
A program called a(n) ____ combines the object program with the programs from libraries.
linker
A program that loads an executable program into main memory is called a(n) ____.
loader
Which phrase describes an example of object-oriented decomposition?
looking for two-factor authentication logical and physical objects that a computer program will manipulate
Several categories of computers exist, such as ____.
mainframe, midsize, and micro
Main memory is an ordered sequence of items, called ____.
memory cells
A(n) ____ consists of data and the operations on those data.
object
The devices that the computer uses to display results are called ____ devices.
output
Which term refers to the process of finding similarities in procedures and tasks?
pattern identification
Which of the following is a legal identifier? program_1 1program program! program 1
program_1
Main memory is called ____.
random access memory
____ is a parameterized stream manipulator.
setfill
Dividing a problem into smaller subproblems is called ____ design.
structured
Suppose that sum and num are int variables and sum = 5 and num = 10. After the statement sum += num executes, ____. sum = 15 sum = 0 sum = 10 sum = 5
sum = 15
The ____ rules of a programming language tell you which statements are legal, or accepted, by the programming language.
syntax
Information stored in main memory must be transferred to some other device for permanent storage.
true
The maximum number of significant digits in float values is up to 6 or 7.
true
What phrase identifies an example of single classification of objects from a classification pattern?
vehicles represented as cars