COSC 1436 Midterm Review
Of the following, which is a valid C++ identifier?
-June1997 -_employee_number -____department -myExtraLongVariableName
At the heart of a computer is its central processing unit. The CPUs jobs is:
-To fetch instructions -To carry out the operations commanded by the instructions -To produce some outcome or resultant information
In a C++ program, two slash marks (//) indicate:
The beginning of a comment
What is the value stored at x, given the statements: int x; x = 1 / static_cast<int>(4.5 + 6.4);
0
This manipulation is used to establish a field width for the value immediately following it
set w
the first step in testing the string class is to #include the _____ header file.
string
During which stage does the central processing unit retrieve from main memory the next instruction in the sequence of program instructions?
Fetch
What will the following code display? cout << "four\n" << "score\n"; cout << "and" << "\nseven"; cout << "\nyears" << " ago" << endl;
Four score and secen years ago
Besides decimal, two other number systems you might encounter in C++ programs are:
Hexadecimal and Octal
The computer's main memory is commonly known as:
RAM
A variable's ________ is the part of the program that has access to the variable
Scope
Even when there is no power to the computer, data can be held in:
Secondary storage
An example of a secondary storage is:
The disk drive
The purpose of a memory address is:
To identify the location of a byte in memory
Programmer defined names of memory locations that may hold data are:
Variables
________ represent storage locations in the computer's memory
Variables
Which character signifies the beginning of an escape sequence?
\
Which escape sequence causes the cursor to move to the beginning of the current line?
\r
The ___________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.
cin object
Which of the following defines a double-precision floating point variable named payCheck?
double payCheck;
To use the rand() function, you must #include this header file in your program
cstdlib
The total number of digits that appear before and after the decimal point is sometimes referred to as:
significant digits and precision
Which statement is equivalent to the following: x = x*2
x *= 2;
What statement best describes a variable and its primary purpose?
A variable is a named storage location in the computer's memory used for holding a piece of information.
You must have a ___________ for every variable you intend to use in a program.
Definition
In C++ 11, if you want an integer literal to be treated as a long int, you can append ______ at the end of the number
LL
These are date items whose values do not change while the program is running
Literals
Mistakes that cause a running program to produce incorrect results are called:
Logic errors
In a broad sense, the two primary categories of programming languages are:
Low-level and High-level
This is a set of rules that must be followed when constructing a program.
Syntax
The ______ decodes an instruction and generates electrical signals.
Control Unit
In programming terms, a group of characters inside a set of quotation marks is called a(n):
String literal
In any program that uses the cin object, you must included the ______
iostream header file
What is the modulus operator?
%
Which line in the following program will cause a compiler error? 1 #include <iostream> 2 using namespace std; 3 4 int main() 5 { 6 const int MY_VAL = 77; 7 MY_VAL = 99; 8 cout << MY_VAL << endl; 9 return 0; 10 }
7
Assuming you are using a system with 1-byte characters, how many bytes of memory will the following string literal occupy? "William"
8
The ______ operator always follows the cin object, and the _____ operator follows the cout object
>>,<<
The programmer usually enters source code into a computer using:
A text editor
Three primary activities of a program are:
Input, processing, output
Associativity is either right to left or:
Left to right
The ______ causes the content of another file to be inserted into a program
#include directive
Assume that x is an int variable. What value is assigned to x after the following assignment statement is executed? x = -3 + 4 % 6 / 5;
-3
an integrated Development Environment typically consists of:
-A text editor -A compiler -A debugger
When a variable is assigned a number that is too large for its data type, it:
Overflows
When converting some algebraic expressions to C++, you may need to insert ___________ that do not appear in the algebraic expression.
Parentheses
Which of the following is not one of the five major components of a computer system?
Preprocessor
You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?
cin >> length >> width >>height;
This statement will pause the screen, until the [Enter] key is pressed
cin.get();
What will the value of x be after the following statements execute? int x = 0; int y = 5; int z = 4; x = y + z * 2;
13
What is the value of cookies after the execution of the following statement? int number = 38, children = 4, cookies; cookies = number % children;
2
What will the value of result be after the following statement executes? result = 6 - 3 * 2 + 7 - 10 / 2 ;
2
What will the value of x be after the following statements execute? int x; x = 10 % 4;
2
What is the value of the number after the following statements execute? int number = 10; number += 5; number -= 2; number *= 3;
39
What will the value of x be after the following statements execute? int x; x = 10 / 4;
4
What is the value of average after the following code executes? double average; average = 1.0 + 2.0 + 3.0 / 3.0;
4.0
A set of well-defined steps for performing a task or solving a problem is know as a(n);
Algorithm
Which of the following best describes an operator?
An operator allows you to perform operations on one or more pieces of data.
_______ are used to translate each source code instruction into the appropriate machine language instructions
Compilers
Which is true about the following statement? cout << setw(4) << num4 << " ";
It allows four spaces for the value in the variable num4
What will the following code display? cout << "Monday"; cout << "Tuesday"; cout << "Wednesday";
MondayTuesdayWednesday
The statement: cin >> setw(10) >> str; will read up to this many characters into str.
Nine
in memory, C++ automatically places a ______ at the end of string literals
Null terminator
A(n) ____ is the most fundamental set of programs on a computer
Operating system
Characters of symbols that perform operations on one or more operands are:
Operators
This is used in a program to mark the beginning or ending of a statement, or separate items in a list.
Punctuation
This is used to mark the end of a complete C++ programming statement.
Semicolon
The statements written by the programmer are called:
Source code
This is a complete instruction that causes the computer to perform some action.
Statement
Internally, the CPU consists of two parts:
The control Unit and the Arithmetic and Logic Unit
When the final value of an expression is assigned to a variable, it will be converted to:
The data type of the variable
________ must be included in any program thatuses the cout object
The header file iostream
Which data type typically requires only one byte of storage?
char
This function tells the cin object to skip one or more characters in the keyboard buffer.
cin.ignore();
The function, pow(x, 5.0), requires this header file.
cmath
When using the sqrt function you must include this header file.
cmath