COP 3014 Programming I Final Ch 1-8
Which of the following is false about the following function prototype? void functionA( void ); It could have been written functionA( void ); It could have been written void functionA( ); It does not return a value. It does not receive any arguments.
FALSE: It could have been written functionA( void ); void is the type in this case and is needed
Which of the following is false? The last element of an array has position number one less than the array size. The position number contained within square brackets is called a subscript. A subscript cannot be an expression. All of the above.
FALSE: A subscript cannot be an expression.
Which of the following statements is false about a function to which an array is being passed? Answers: The array name is used as an argument in the function call. It is being passed the address of the first element in the array. It always knows the size of the array that is being passed. It is able to modify the values stored in the array.
FALSE: It always knows the size of the array that is being passed. --Function doesn't always know this.
Which of the following is false for pointer-based strings? A string in C++ is an array of characters ending in the null character ('\0'). A string may be assigned in a declaration to either a character array or a variable of type char *. A string may include letters, digits and various special characters (i.e., +, -, * ). String literals are written inside of single quotes.
FALSE: String literals are written inside of single quotes. They use double quotes.
Which of the following is not true of pointers to functions? They can be stored in arrays. They can not be assigned to other function pointers. They are dereferenced in order to call the function. They contain the starting address of the function code.
FALSE: They can not be assigned to other function pointers.
Which of the following is not true of pointers to functions? They contain the starting address of the function code. They can not be assigned to other function pointers. They are dereferenced in order to call the function. They can be stored in arrays.
FALSE: pointers to function can not be assigned to other function pointers. i.e. they can
Which of the following statements is false? The commas used to separate the arguments in a function call are comma operators. The order of evaluation of a function's arguments is not specified by the C++ standard. The comma operator guarantees that its operands are evaluated left to right. The C++ standard guarantees that all arguments in a function call are evaluated before the called function executes.
False: The commas used to separate the arguments in a function call are comma operators. note: The value of a comma-separated list of expressions is the value of the right-most expression.
In an activity diagram for an algorithm, what does a solid circle surrounded by a hollow circle represent? Initial state. Action state. Transition. Final state.
Final state.
The Internet is a _____.
Global network of computers
std::cout << "Hello "; std::cout << "World"; Hello World World Hello Hello World World Hello
Hello World There is no new line output so it prints on the same line. Notice the space after Hello, also.
Which of the following types of software made it cheaper and easier to start Web 2.0 companies? Proprietary. Open source. Vaporware. None of these.
Open source
Which of the following statements are true about Function Signatures and Overloaded Functions? Select all that apply. Overloaded functions are distinguished by their signatures. A signature is a combination of the function's name and parameter types. In the function signature, the order of the parameter types does not matter. Overloaded functions with identical parameter lists but different return types will be distinguished properly by the compiler.
Overloaded functions are distinguished by their signatures. (diff param lists) A signature is a combination of the function's name and parameter types.
Consider the following function: void reverse( char *string1, const char *string2 ) { int stringsize = sizeof( string1 )/sizeof( char ); *( string1 + stringsize - 1 ) = '\0'; string1 = string1 + stringsize - 2; for ( ; *string2 != '\0'; string1--, string2++ ) *string1 = *string2; } What method does the function use to refer to array elements?
Pointer/offset notation. for ex: *( bPtr + 3 ) The 3 in the preceding expression is the offset to the pointer.
Which of the following operations has the highest precedence? Postincrement. Assignment. Multiplication. Addition
Postincrement or postfix. (a++) in order: postfix, prefix, pointer, mult/div/mod, +/-, etc. http://en.cppreference.com/w/cpp/language/operator_precedence
Specifying the order in which statements are to be executed in a computer program is called: Pseudocode. An algorithm. Transfer of control. Program control.
Program control. A simple C++ statement is each of the individual instructions of a program, like the variable declarations and expressions seen in previous sections. They always end with a semicolon ( ; ), and are executed in the same order in which they appear in a program.
sizeof:
Returns the total number of bytes in a variable.
Indefinite repetition is controlled by a: Counter. Sentinel value. Non-constant condition. Absence of a condition.
Sentinel value. example: while (Get(input) !=Sentinel) { Process(input); } also called a flag-controlled while loop
In indefinite repetition, an input value: Should always be processed directly after it is entered. Should never be modified. Should always be evaluated before being processed. Can be entered, processed, and evaluated in any order.
Should always be evaluated before being processed.
Which of the following is not one of the three general types of computer languages? High-level languages. Machine languages. Spoken languages. Assembly languages.
Spoken languages.
Which of the following statements about the C++ Standard Library is false: The C++ Standard Library consists of classes and functions that perform tasks. An advantage of using classes and functions from the C++ Standard Library is saving the effort of designing, developing and testing new classes. The C++ Standard Library functions and classes are not included in every C++ implementation. The C++ Standard Library is an important part of the C++ world.
The C++ Standard Library functions and classes are not included in every C++ implementation. This is incorrect. C++ Standard Library functions are included in all implementations by default.
Which statement about insertion sort is true?
The algorithm is simple compared to other sorting procedures.
To prevent modification of array values passed to a function: The array must be passed by reference. A copy of the array must be made inside the function. The array must be declared static in the function. The array parameter can be preceded by the const qualifier.
The array parameter can be preceded by the const qualifier.
To prevent modification of array values passed to a function: The array parameter can be preceded by the const qualifier. A copy of the array must be made inside the function. The array must be declared static in the function. The array must be passed by reference.
The array parameter can be preceded by the const qualifier.
If a do...while structure is used: The body of the loop will execute at least once. Counter-controlled repetition is not possible. An infinite loop cannot take place. An off-by-one error cannot occur.
The body of the loop will execute at least once.
Call-by-reference can achieve the security of call-by-value when: The const qualifier is used. A large argument is passed in order to improve performance. A pointer to the argument is used. The value being passed is small.
The const qualifier is used.
After the ith iteration of the insertion sort: The ith element of the array is currently empty. The ith element of the array is in its final position. The first i elements of the array are sorted. The last i elements of the array are sorted.
The first i elements of the array are sorted.
Which of these describe the benefits of using functions?
They allow reusability - can be used as building blocks in other programs They make development more manageable; Divide and conquer They allow a programmer to modularize a program They help eliminate redundant code
Comparing pointers and performing pointer arithmetic on them is meaningless unless: They point to elements of the same array. They point to arrays of the same type. You are trying to compare and perform pointer arithmetic on the values to which they point. They point to arrays of equal size.
They point to elements of the same array.
Which of the following statements about the for statement is false? The initialization and increment expressions can be comma-separated lists. You must declare the control variable before the for statement. The three expressions in the for statement are optional. A for statement can always be used to replace a while statement, and vice versa.
This as false, as you don't have to, you can do it in the for (int x = 0; x < 3; x++). You must declare the control variable before the for statement. For the first answer, yes they can be, but outside the (). CONFUSING!
What will be the output after the following C++ statements have been executed? int a, b, c, d; a = 4; b = 12; c = 37; d = 51; if ( a < b ) cout << "a < b" << endl; if ( a > b ) cout << "a > b" << endl; if ( d <= c ) cout << "d <= c" << endl; if ( c != d ) cout << "c != d" << endl; Answers: a > b c != d a < b d <= c c != d a < b c < d a != b a < b c != d
This is just screen output a < b c != d
What are four characteristics of variables? Type Size Name Character Value Function Algorithm Integer
Type Size Name Value NV ST.
Which operation does not take place in the following example? int x = 21; double y = 6; double z = 14; y = x / z; x = 5.5 * y; Promotion. Truncation. Explicit conversion. Implicit conversion.
answer: explicit conversion promotion and implicit conversion are the same thing truncation rounds to the lower whole number explicit conversion uses casting
Linear search can be used on: Unsorted arrays. Sorted arrays. Integer arrays. any of these
any array
The term function overloading refers to the way C++ allows more than one function in the same scope to share the same name -- as long as they have different parameter lists
as long as they have different parameter lists
Size, shape, color, weight, height and number of doors are all good examples of
attributes.
Which of the following will not increment c by 1? c + 1; c += 1; c++; ++c;
c + 1; this is invalid.
Which of the following is not a valid enumeration statement? enum person { me, you, me }; enum person { me, you, them }; enum person { me = 0, you = 0, them = 0 }; enum person { me = 1, you = 2, them = 3 };
enum person { me, you, me }; there are duplicate variable names
All of the following are true of functions except: The definition of a function usually is visible to other functions. The implementation of a function is hidden from the caller. They define specific tasks that can be used at many points in a program. A function call must specify the name and arguments of the function.
false: The definition of a function usually is visible to other functions.
Which of the following for headers is not valid? All of the above. int i = 0; for ( ; i < 10; i++ ) for ( int i = 0; i < 10; i++ ) for ( int i = 0; int j = 5; ; i++ )
for ( int i = 0; int j = 5; ; i++ ) uses 2 variable names
Which of the following is not included in <cmath>? log pow floor ln
ln
Which of the following are logical operators: == equal to <= Less than or equal to !! OR >= greater than or equal to ! Negate && AND
logical operators are &&, ! , | |
The & operator can be applied to: constants. rvalues. lvalues. string literals.
lvalues. pointer operator
Which of the following is not a valid C++ identifier? width m_x _AAA1 my Value
my Value, because of the space
Which of the following best describes the array name n in the declaration int n[10];? n is a constant pointer to nonconstant data. n is a nonconstant pointer to constant data. n is a nonconstant pointer to nonconstant data. n is a constant pointer to constant data.
n is a constant pointer to nonconstant data.
The std::endl stream manipulator________. terminates the program. flosses the output buffer. Correct outputs a newline and flushes the output buffer. inputs a newline.
outputs a newline and flushes the output buffer.
If grade has the value of 60, what will the following code display? if ( grade >= 60 ) cout << "Passed"; cout << "Passed"; 60 Passed nothing.
passed
Assuming that x is equal to 4, which of the following statements will not result in y containing the value 5 after execution? y = x + 1; y = ++x; y = 5; y = x++;
postfix y = x++; happens after the statement is executed
Depending on the circumstances, the compiler may ignore the storage class specifier: static register auto extern
register
Which of the following is not one of the C++ control structures? do...while if switch select
select selection is a form of control, but it is not a control structure it's called selection structure which contains if, if...else and switch do...while is repetition structure
All programs can be written in terms of only three control structures: Sequence structure Selection structure Repetition structure
sequence, selection, repetition
The ___, ___ and ___ are the only three forms of control necessary. switch, if, else break, continue, if...else sequence, selection, repetition for, while, do...while
sequence, selection, repetition these are all 3 control structures
Which of the following expressions returns the trigonometric sine of x? Answers: sin( x ) sine( x ) trig_sine( x ) trig_sin( x )
sin( x )
The ________ object enables a program to read data from the user. std::cget. std::cout. std::cin. std::cread.
std::cin . (c - in )
Which of the following statements could potentially change the value of number2? std::cin >> number2; sum = number1 + number2; number1 = number2; std::cout << number2;
std::cin >> number2;
What is wrong with the following while loop? while ( sum <= 1000 ) sum = sum - 30; The parentheses should be braces. sum = sum - 30 should be sum = sum + 30 or else the loop may never end. There should be a semicolon after while ( sum <= 1000 ). Braces are required around sum = sum - 30;.
sum = sum - 30 should be sum = sum + 30 or else the loop may never end.
If x initially contains the value 3, which of the following sets x to 7? x =+ 4; x += 4; x ++ 4; x + 4 = x;
x += 4; x = x + 4 x = 3 + 4 x = 7
Assuming that x and y are equal to 3 and 2, respectively, after the statement x -= y executes, the values of x and y will be: x: 5; y: 3 x: 1; y: 2 x: 3; y: -1 x: 3; y: 5
x: 1; y: 2 x = x-y x = 3-2 x = 1 y=2
In the expression n = x + rand() % y; y is the scaling value. Both (a) and (b). x is the scaling value. y is the shifting value.
y is the scaling value.
Three of the following expressions have the same value. Which of the following expressions has a value different from the others'? &*ptr *&ptr ptr *ptr
&*ptr - &* cancel each other out *&ptr - &* cancel each other out ptr . - same as above to *ptr - points to the address
Assuming that t is an array and tPtr is a pointer to that array, which expression refers to the address of element 3 of the array? &t[ 3 ] *( t + 3 ) *( tPtr + 3 ) tPtr[ 3 ]
&t[ 3 ]
In what order would the following operators be evaluated -, *, /, +, % Assume that if two operations have the same precedence, the one listed first will be evaluated first. -, *, %, +, / -, +, %, *, / +, -, /, *, % *, /, %, -, +
*, /, %, -, + remember pemdas mult, div, mod, sub, add
For which of the following operators does C++ not specify the order of evaluation of its operands? , ?: && +
+
Which of the following can have a pointer as an operand? *= / % ++
++ ex: pointer++
What is the value of result after the following C++ statements execute? int a, b, c, d, result; a = 4; b = 12; c = 37; d = 51; result = d % a * c + a % b + a;
119 PEMDAS and remember mod (%) is the whole number remainder. So mod 4 of 12 is 4 because 12 doesn't divide into it. 51%4 x 37 + (4) + 4 3x37 + 8 111 + 8 = 119
Given that k is an integer array starting at location 2000, kPtr is a pointer to k and each integer is stored in 4 bytes of memory, what location does kPtr + 3 point to?
2012 2000 +1 = 2004 +2 = 2008 +3 = 2012
What value does function mystery return when called with a value of 4? int mystery ( int number ) { if ( number <= 1 ) return 1; else return number * mystery( number - 1 ); } Answers: 0 24 4 1
24 recursive function
Assuming the following pseudocode for the Fibonacci series, what is the value of fibonacci(5)? fibonacci( 0 ) = 0 fibonacci( 1 ) = 1 fibonacci( n ) = fibonacci( n - 1 ) + fibonacci( n - 2 ) 3 7 1 5
5
Consider the following code, assuming that x is an int with an initial value of 12 if( x = 6 ) cout << x; What is the output? Nothing. A syntax error is produced. 6 12
6
Which of the following C++ Standard Library header files does not contain a C++ Standard Library container class? <list> <string> <vector> <stack>
<string>
The assignment operator ________ assigns the value of the expression on its right to the variable on its left. # = -> <-
= (don't mix up with == which is a relational operator like !=, >, <, >=, <=)
Each of the following is a relational or equality operator except: > <= == =!
=! - because it should be != (works right to left)
An operator that associates from right to left is: , ?: != ()
?: ternary
Choose the required parts of a function prototype: List of data types it will receive The type of value the function will return The order of parameter types Name of function
A B (C , D) A - type it will return B - name of function C and D- Data types finally, the order of c and d
To follow the principle of least privilege, the selectionSort function should receive the array to be sorted as: A nonconstant pointer to constant data. A constant pointer to constant data. A constant pointer to nonconstant data. A nonconstant pointer to nonconstant data.
A constant pointer to nonconstant data.
To handle situations where a loop must reinitialize a variable at the beginning of each iteration, such re-initialization could be performed by: A declaration after the loop body. A declaration inside the loop body. An assignment statement before the loop body. An assignment statement after the loop body.
A declaration inside the loop body.
If the function int volume( int x = 1, int y = 1, int z = 1 ); is called by the expression volume( 3 ), how many default arguments are used? Two. One. None. Three.
A default argument is a value provided in function declaration that is automatically assigned by the compiler if caller of the function doesn't provide a value for the argument with default value. Two
A function prototype can always be omitted when: A function is defined before it's first invoked. A function takes no arguments. A function does not return a value. A function is invoked before it's first defined.
A function is defined before it's first invoked.
An activation record will be popped off the function call stack whenever: A function returns control to its caller. A function calls itself. A function declares a local variable. A function calls another function.
A function returns control to its caller.
A function that prints a string by using pointer arithmetic such as ++ptr to output each character should have a parameter that is: A nonconstant pointer to nonconstant data. A nonconstant pointer to constant data. A constant pointer to constant data. A constant pointer to nonconstant data.
A nonconstant pointer to constant data.
A pointer can not be assigned to:
A pointer of a type other than its own type and void without using the cast operator.
An algorithm is: A main function with calls to many other functions. A procedure for solving a problem in terms of the order in which actions will execute. A collection of variables. A procedure for solving a problem in terms of the actions to execute.
A procedure for solving a problem in terms of the order in which actions will execute. A procedure for solving a problem in terms of the actions to execute.
The following arithmetic operations may be performed on pointers. Choose all that apply: Increment/Decrement a pointer. Divide a pointer by an integer. Add one pointer to another pointer. Subtract one pointer from another pointer. Add an integer to a pointer. Subtract an integer from a pointer. Multiply a pointer by an integer.
ADDITION AND SUBTRACTION Increment/Decrement a pointer. Subtract one pointer from another pointer. Add an integer to a pointer. Subtract an integer from a pointer.
___ is a set of methodologies that try to get software implemented quickly with fewer resources than previous methodologies.
Agile software development
Which of the following data types can be used to represent integers? All of the above. short char long
All of the above.
Which of the following does counter-controlled repetition require? An initial value. A condition that tests for the final value. An increment or decrement by which the control variable is modified each time through the loop. All of the above.
All of the above. (int i = 0; i <10; i++)
Which of the following is a compilation error? All of these. Placing a space between the symbols in the <= operator. Using a triple equals sign instead of a double equals sign in the condition of an if statement. Omitting the left and right parentheses for the condition of an if statement.
All of these are COMPILATION errors.
Which of the following is/are considered part of Web 2.0? Social networking. All of these. Collective intelligence. Community-generated content.
All of these.
How many times will the following loop print hello? i = 1; while ( i <= 10 ) cout << "hello"; An infinite number of times 10 0 9
An infinite number of times because the counter (i=1) is never incremented, i always = 1.
Which of the following statements would display the phrase C++ is fun? std::cout << "Thisis fun\rC++ "; std::cout << "\"C++ is fun\""; std::cout << C++ is fun; std::cout << '++ is fun';
Answer: std::cout << "Thisis fun\rC++ "; \r is carriage return, but without /n it just returns to the beginning of the line. "C++ " covers up "This" and becomes C++ is fun.
Consider the execution of the following for loop for (int x = 1; x < 5; increment ) cout << x + 1 << endl; If the last value printed is 5, which of the following might have been used for increment? x++ x += 1 ++x Any of the above.
Any of the above.
Which of the following is not one the rules for forming structured programs? Any action state can be replaced by two action states in sequence. Any action state can be replaced by any control statement. Any transition arrow can be reversed. Begin with the 'simplest activity diagram.'
Any transition arrow can be reversed.
float and double variables should be used: As approximate representations of decimal numbers. As counters. To store true/false values. To perform monetary calculations.
As approximate representations of decimal numbers.
Pointers may be assigned which of the following values? Any integer values. An address. NULL Correct Both (b) and (c).
Both (b) and (c). INT/ADDRESS
Unless otherwise specified, entire arrays are passed __________ and individual array elements are passed __________. By reference, by value. By value, by value. By value, by reference. By reference, by reference.
By reference, by value.
Which of the following is not a valid way to pass arguments to a function in C++? By reference with reference arguments. By value. By value with pointer arguments. By reference with pointer arguments
By value with pointer arguments.
Using the following function definition, the parameter list is represented by: A B ( C ) { D }
C
Today, virtually all new major operating systems are written in:
C or C++
Which language was developed expressly for the .NET platform?
C#
Which of the following languages was designed for precise, efficient manipulation of large amounts of data? COBOL. Pascal. Fortran. Basic.
COBOL - common business oriented language
Referencing elements outside the array bounds: Is impossible because C++ checks to make sure it does not happen. Is a syntax error. Enlarges the size of the array. Can result in changes to the value of an unrelated variable.
Can result in changes to the value of an unrelated variable. all of the other things are not true
srand: Should be called before each call to rand. Is unnecessary in C++. Should be used instead of rand to generate truly random numbers. Can use the time function's return value as an optimal seed value.
Can use the time function's return value as an optimal seed value.
Which of the following is a logical unit of a computer that represents the --administrative-- section?
Central processing unit.
A string array is commonly used for:
Command-line arguments.
Which of the following statements is true? None of these. Interpreted programs run faster than compiled programs. Interpreter programs use assembly language as input. Compilers translate high-level language into machine language.
Compilers translate high-level language into machine language.
Which of the following encompasses the other three? Sequence structure. Repetition structure. Selection structure. Control structure.
Control structure. three types of control structures: repetition, sequence, selection
Which of the following is not a syntax error? std::cout << Hello world!; std::cout << "Hello world! "; std::cout << "Hello world! "; std::cout << 'Hello world! ';
Correct std::cout << "Hello world! "; problems: (no quotes) (two lines) (single quotes)
In regards to default arguments, which of the following is false? Default values cannot be global variables or function calls. Default values can be constants. They must be the rightmost (trailing) arguments in a function's parameter list. When an argument is omitted in a function call, the default value of that argument is automatically inserted by the compiler and passed in the function call.
Default values cannot be global variables or function calls. they can
The development of the Internet was originally funded by which U.S. agency?
Department of Defense.
When an argument is passed-by-value, changes in the called function __________ affect the original variable's value; when an argument is passed call-by-reference, changes in the called function __________ affect the original variable's value. Answers: Do, do Do not, do not Do, do not Correct Do not, do
Do not, do
In C++, the condition ( 4 > y > 1 ): Does not evaluate correctly and should be replaced by ( 4 > y && y > 1 ). Does not evaluate correctly and should not be replaced by ( 4 > y && y > 1 ). Evaluates correctly and could be replaced by ( 4 > y && y > 1 ). Evaluates correctly and could not be replaced by ( 4 > y && y > 1 ).
Does not evaluate correctly and should be replaced by ( 4 > y && y > 1 ).
Which of the following statements does not cause a syntax error to be reported by the C++ compiler? Missing */ in a comment. Mismatched {}. Missing ; at the end of a statement. Extra blank lines.
Extra blank lines. blank lines don't matter, unless they break up a statement.
C++ is a:
Hybrid object-oriented language.
Which of the following statements is true? None of these. In distributed computing, an organization's computing is distributed over networks to the sites where the organization's work is being performed. In distributed computing, an organization s computing is performed at a central computer installation. In distributed computing, an organization s computing is handled by a computer distributor.
In distributed computing, an organization's computing is distributed over networks to the sites where the organization's work is being performed.
A function prototype does not have to: Terminate with a semicolon. Match with all calls to the function. Agree with the function definition. Include parameter names.
Include parameter names. (variables)
Java was originally developed for:
Intelligent consumer devices.
A block: Is a compound statement. Must contain exactly three statements. Correct Is a compound statement. Cannot contain declarations. Is represented by placing a semicolon (;) where a statement would normally be.
Is a compound statement. i.e. more than one line of code in a statement
A string array:
Is actually an array of pointers.
A reference parameter: Is an alias for its corresponding argument. Is declared by following the parameter's type in the function prototype by an ampersand (&). Cannot be modified. Both (a) and (b).
Is an alias for its corresponding argument. Is declared by following the parameter's type in the function prototype by an ampersand (&). note: The ability to pass by reference exists for two reasons: To modify the value of the function arguments To avoid make copies of an object for performance reasons
The conditional operator (?:): Associates from left to right. Is the only ternary operator in C++. Accepts two operands. Is a unary operator.
Is the only ternary operator in C++.
Which of the following is true of pseudocode? All of the above are false. It is executed by the computer. It includes declarations and all types of statements. It helps the programmer 'think out' a program.
It helps the programmer 'think out' a program.
Using a while loop's counter-control variable in a calculation after the loop ends often causes a common logic error called: A fatal logic error. A syntax error. A counter exception. An off-by-one error.
LOGIC error The program usually compiles but gives the wrong answer An off-by-one error.
Linear search is highly inefficient compared to binary search when dealing with: Large, unsorted arrays. Small, sorted arrays. Small, unsorted arrays. Large, sorted arrays.
Large, sorted arrays.
An array is not:
Made up of different data types.
The linker links: The executable code with primary memory. The source code with the object code. The object code with the external libraries. The primary memory with the CPU.
Mnemonic: Library Linker The object code with the external libraries.
In a switch structure: A break is required after the default case. A default case is required. Multiple actions in a case do not need to be enclosed in braces. A break is required after each case.
Multiple actions in a case do not need to be enclosed in braces.
Which of the following statements about object-oriented design is false? OOD encapsulates attributes and operations into objects. OOD focuses on actions (verbs). OOD takes advantage of inheritance relationships. Each class can be used to create multiple objects.
OOD focuses on actions (verbs). False: OOD focuses on objects/nouns.
What does the following statement declare? int *countPtr, count;
One pointer to an int and one int variable.
Which of the following is the escape character? * \n " \
\ is the escape character (see http://www.cplusplus.com/doc/tutorial/constants/)
The escape sequence for a newline is: \a \t \r \n
\n \ = escape character \t is tab \r is carriage return \a is alert http://www.cplusplus.com/doc/tutorial/constants/
The other classes or functions that use a certain class are commonly referred to as its ______
clients.
Which of the following does not perform the following task: display correct if answer is equal to 7 and incorrect if answer is not equal to 7? cout << ( answer == 7 ? "correct" : "incorrect" ); cout << answer == 7 ? "correct" : "incorrect"; answer == 7 ? cout << "correct" : cout << "incorrect"; if ( answer == 7 ) cout << "correct"; else cout << "incorrect";
cout << answer == 7 ? "correct" : "incorrect";
Which of the following is a double-selection statement? switch if Correct if...else do...while
if...else
What will the following program segment do? int counter = 1; do { cout << counter << " "; } while ( ++counter <= 10 ); Print the numbers 1 through 9. Print the numbers 1 through 11. Cause a syntax error. Print the numbers 1 through 10
in a do while the control statement can equal the numbers you are testing (1-10) Print the numbers 1 through 10
Which of the following statements does not overwrite a preexisting value stored in a memory location? y = y + 2; number = 12; width = length; int a;
int a; this is just declaring the type. The rest of these answers are overwriting a possible value for a variable (y, number, width).
Which statement would be used to declare a 10-element integer array c? array c = int[ 10 ]; int c[ 10 ]; c = int[ 10 ]; int array c[ 10 ];
int c[ 10 ];
switch can be used to test: string constants. float constants. all types of constants. int constants.
int constants, i.e. 1, 2, 3, 4, 5.
Which of the following is not a correct way to initialize an array? int n[] = { 0, 7, 0, 3, 8, 2 }; int n[ 5 ] = { 7 }; int n[ 5 ] = { 9, 1, 9 }; int n[ 5 ] = { 0, 7, 0, 3, 8, 2 };
int n[ 5 ] = { 0, 7, 0, 3, 8, 2 }; 5 in subscript, 6 ints in the {}
Converting from type ___ to type ___ will result in the loss of data. int, char float, double bool, char short, long
int, char this is the only one that goes from bigger to smaller char - 1 byte bool - 1 byte short - 2 bytes int - 4 bytes float - 4 bytes long - 4 bytes double - 8 bytes so in order: loss promotion equal promotion https://stackoverflow.com/questions/589575/what-does-the-c-standard-state-the-size-of-int-long-type-to-be
Of the following, which is NOT a LOGIC error? Not placing curly braces around the body of an if that contains two statements. Using == to assign a value to a variable. Failing to initialize counter and total variables before the body of a loop. Using commas instead of the two required semicolons in a for header.
they are all errors, but this is a SYNTAX error Using commas instead of the two required semicolons in a for header.
All of the following can cause a fatal EXECUTION-TIME error except: Dereferencing a variable that is not a pointer. Dereferencing a pointer that has not been initialized properly. Dereferencing a null pointer. Dereferencing a pointer that has not been assigned to point to a specific address.
this is another type of error: Dereferencing a variable that is not a pointer.
The rand function generates a data value of the type: long int unsigned int int short int
unsigned int Unsigned can hold a larger positive value, and no negative value. Unsigned uses the leading bit as a part of the value, while the signed version uses the left-most-bit to identify if the number is positive or negative.