Intro to C++
double
Look at the following function protoype. int myFunction(double); What is the data type of the function's parameter variable?
<
Look at the following statement. while (x++ <10) which operator is used first?
All of the above are valid identifiers
Of the following, which is a valid C++ identifier?
infinite loop
Something within a whle loop must eventually cause the condition to become false, or a(n) _____ results.
Nine
The Statement: cin >> setw(10) >> str: will read up to this many characters into str.
trailing else
The default section of a switch statement performs a similar task as the _____ portion of an if/else if statement.
single, double
The float data type is considered _____ precision, and the double data type is considered _____ precision.
false
The preprocessor executes after the compiler
static local
The value in a _____ variable persists between function calls.
static
The value in this type of local variable persists between function calls.
a statement or block that is repeated as long as the expression is true.
The while loop has two important parts: an expression that is tested for a true or false value, and:
Literals
These are data items whose values do not change while the program is running.
Floating point data types
These are used to declare variables that can hold real numbers.
exit ( )
This function causes a program to terminate, regardless of which function or control mechanism is executing.
function
This is a collection of statements that performs a specific task.
stub
This is a dummy function that is called instead of the actual function it represents.
Syntax
This is a set of rules that must be followed when constructing a program
function call
This is a statement that causes a function to execute.
RAM
This is a volatile type of memory, used for temporary storage.
steam insertion operator
This may be used to write information to a file.
!
This operator performs a logical NOT operation.
return
This statement causes a function to end.
cin.get () ;
This statement will pause the screen, until the [Enter] key is pressed.
Compiling
This step will uncover any syntax errors in your program.
fixed
This stream manipulator forces cout to print the digits in fixed-point notation.
ifstream
To read data from a file, you define an object of this data type.
False
True/False: A function's return data type must be the same as the function's parameter(s).
True
True/False: A static variable that is defined within a function is initialized only once, the first time the function is called.
True
True/False: As a rule of style, when writing an i f statement you should indent the conditionally-executed statements.
True
True/False: Escape sequences are always internally as a single character.
False
True/False: If you want to know the length of the string that is stored in a string object, you can the object's size member function.
True
True/False: It is possible for a function to have some parameters with default arguments and some without.
False
True/False: Local variables are initialized to zero by default.
False
True/False: Machine language is an example of a high-level language.
True
True/False: One reason for using functions is to break programs into manageable units, or modules.
True
True/False: The CPU is the most important component in a computer because without it, the computer could not run software.
True
True/False: The cin <<statement will stop reading input when it encounters a newline character.
False
True/False: The condition that is tested by a while loop must be enclosed in parentheses and terminated with a semicolon.
True
True/False: The only difference between the get function and the >> operator is that get reads the character typed, even if it is a space, tab, or the [Enter} key.
False
True/False: The scope of a variable declared in a for loop's initialization expression always extends beyond the body of the loop.
False
True/False: You may not use the break and continue statements within the same set of nested loops.
False
True/False: You may not use the break statement in a nested loop.
True
True/False: You may use the exit () function to terminate a program, regardless of which control mechanism is executing.
True
True/False: You should be careful when using the equality operator to compare floating point values because of potential round-off errors.
True
True/Fasle: C++ 11 introduces an alternative way to define variables, using the template key word and an initialization value.
True
True/Flase: When the fixed manipulator is used, the value specified by the setprecision mainipulator will be the number of digits to appear after the decimal point.
The physical components that a computer is made of
What does the term hardware refer to?
1
What is assigned to the variable a given the statement below with the following assumptions: x = 10, y = 7, and z, a, and b are all int variables. a = x >= y;
default
A _____ argument is passed to a parameter when the actual argument is left out of the function call.
global
A _____ variable is declared outside all functions.
scoop
A variable's _____ is the part of the program that has access to the variable.
program
A(n)_______ is a set of instructions that the computer follows to solve a problem.
15
After execution of the following code, what will be the value of input_value if the value 0 is entered at the keyboard at run time? cin >> input_value; if (input_value>5) input_value= input_value+5; else if (input_value >2) input_value=input_value +10; else input_value = input_value +15;
Left to right
Associativity is either right to left or:
Hexadecimal and Octal
Besides decimal, two other number systems you might encounter in C++ program are:
operators
Characters or symbols that perform operations on one or more operands are:
decode
During which stage does the central processing unit analyze the instruction and encode it in the form of a number, and then generate an electronic signal?
secondary storage
Even when there is no power to the computer, data can be held in:
call
Functions are ideal for use in
answer = 1
Given that, x=2, y=1, and z=0, what will the following cout statement display? cout << "answer= " << (x II !y && z) << endl;
20
How many times will the following loop display "Hello"? for (int i=0; i <20; i++) cout << "Hello!" << endl;
header
If a function does not have a prototype, default arguments may be specified in the function _______.
persist
If a function is called more than once in a program, the values stored in the function's local variables do not _____ between function calls.
null statement
If you place a semicolon after the test expression in a while loop, it is assumed to be a(n):
not compile
If you use a C++ key word as an identifier, your program will:
LL
In C++ 11, if you want an integer literal to be treated as a long long int, you can append _____ at the end of number.
auto key word
In C++ 11, the _____ tells the compiler to determine the variable's data type from the initialization value.
Low-level and High-level
In a broad sense, the two primary categories of programming languages are:
initialization
In a for statement, this expression is executed only once.
All of these
In a function header, you must furnish: names of parameter variables, data type(s) of the parameters, the name of function, data type of the return value
The Control Unit and the Arithmetic and Logic Unit
Internally, the CPU consists of two parts:
document
It is a good programming practice to _____ your functions by writing comments that describe what they do.
3
Look at the following function prototype. int myFunction(double, double, double); How many parameter variables does this function have?
3 and 4 are false
1. x == 5; 2. 7 <= (x+2); 3. z <=4; 4. (1 + x) != y; 5. z >= 8; 6. x >= 0; 7. x <= (y * 2)
13
What is the output of the following segment of code if the value 4 is input by the user when asked to enter a number? int num; int total=0; cout <<"Enter a number from 1 to 10:"; cin >> num; switch (num) ( case 1: case 2: total=5; case 3: total=10; case 4: total= total +3; case 8: total= total +6; default: total= total +4; } cout << total << endl;
2
What is the value of cookies after the execution of the following statements? int number = 38, children=4, cookies; cookies = number & children;
12
What is the value of donuts after the following code executes? int donuts = 10; if (donuts !=10) donuts = 0; else donuts += 2;
39
What is the value of number after the following statements execute? int number=10; number += 5; number -= 2; number *= 3;
True
What is the value of the following expression? true && true
0
What is the value stored at x, given the statements: int x; x=3/ static_cast(4.5+6.4);
false
What will be the output of the following code segment after the user enters 0 at the keyboard? int x= -1; cout << "Enter a 0 or a 1 from the keyboard: "; cin >> x; if (x) cout << "true" << endl; else cout << "false" <<endl;
7
What will the following code display? int number = 6; cout << ++number << endl;
7
What will the following code display? int number = 6; ++number; cout << number <<endl;
6
What will the following code display? int number = 6; int x = 0; x = number--;
Fourscore andseven yearsago
What will the following code display? cout <<"Four"<< "score" << endl; cout << "and" << "seven" << endl; cout << "years" << "ago" << endl;
2
What will the value of result be after the following statement executes? result= 6-3*2+7-10/2;
13
What will the value of x be after the following statements execute?
nesting
When an if statement is placed within the conditionally-executed code of another if statement, this is known as:
cmath
When using the sqrt function you must include this header file.
Relational expression
Whereas < is called a relational operator, x < y is called a(n) _____.
\r
Which escape sequence causes the cursor to move to the beginning of the current line?
4
Which line in the following program contains the prototype for the showDub function? 1 #include 2 using namespace std; 3 4 void showDub(int); 5 6 int main( ) 7 { 8 int x = 2; 9 10 showDub (x); 11 cout << x >> endl; 12 return 0; 13 } 14 15 void showDub (int num) 16 { 17 cout << (num *2) <<endl; 18 }
double payCheck;
Which of the following defines-precision floating point variable named payCheck?
#include
Which of the following is a preprocessor directive?
(Parentheses)
You can use these to override the rules of operator precedence in a mathematical expression.
getline
_____ reads a line of input, including leading and embedded spaces, and stores it in a string object.
compilers
_______ are used to translate each source code instruction into the appropriate machine language instruction.
You failed the test! You passed the test!
cout << "Enter a test score! "; cin >> test_score; if (test_score <60); cout <<"you failed the test!" << endl; if (test_score > 60); cout << "You passed the test!" << endl; else cout << "You need to study for the next test!:;