Question 95
Use a stream manipulator that causes the exponent in scientific notation and the letters in hexadecimal values to print in capital letters
b. cout << uppercase; |
Question 96
Find the errors in the following class and explain how to correct them:
class Example {
public:
Example(int y = 10)
: data(y) {
// empty body
} // end Example constructor
int getIncrementedData() const {
return data++;
} // end function getIncrementedData
static int getCount() {
cout << "Data is " << data << endl;
return count;
} // end function getCount
private:
int data;
static int count;
}; // end class Example
c. Error: The class definition for Example has two errors. The first occurs in function getIncrementedData. The function is declared const, but it modifies the object. Correction: To correct the first error, remove the const keyword from the definition of getIncrementedData. Error: The second error occurs in function getCount. This function is declared static, so it is not allowed to access any non-static member of the class. Correction: To correct the second error, remove the output line from the getCount definition. |
Question 97
What output will be produced by the following code?
int count = 3;
while (count-- > 0)
cout << count << " ";
c. 2 1 0 |
Question 98
Which is not a loop structure?
d. Repeat Until |
Question 99
Write the function header for a function called evaluate that returns an integer and that takes as parameters integer x and a pointer to function poly. Function poly takes an integer parameter and returns an integer.
a. int evaluate(int x, int (*poly)(int)) |
Question 100
What is the output of the program below?
#include <iostream>
using namespace std;
int main() {
int y = 99;
int *x = &y;
cout << 3+*x << endl;
return 0;
b. 102 |
Конец формы
Конец формы
Preparation for Final Exam MCQ Quiz BIG - Попытка 1
Страница: 1 2 3 4 5 6 7 8 9 10 (Далее)
Question 1
Баллов: 1
Find the error in the following program segment. Assume the following declarations and statements:
int *zPtr; // zPtr will reference array z
int *aPtr = 0;
void *sPtr = 0;
int number;
int z[ 5 ] = { 1, 2, 3, 4, 5 };
if (strcmp(string1, string2))
cout << "The strings are equal" << endl;
Выберите один ответ.
a. if (strcmp(string1, string2) == 0)
cout << "The strings are equal" << endl;
Question 2
Баллов: 1
The stream manipulators dec, oct and hex affect only the next integer output operation
Ответ:
False
Question 3
Баллов: 1
Which of the following is the proper keyword to allocate memory?
Выберите один ответ. a. new
Question 4
Баллов: 1
Write a declaration for the following: Double-precision, floating-point variable lastVal that is to retain its value between calls to the function in which it is defined.
Выберите один ответ.
c. static double lastVal;
Question 5
Баллов: 1
$$1 Select the best answer to the output of the program:
#include<iostream>
usingnamespace std;
int main() {
double y = 3;
double *x = &y;
cout << x << " " << x+1 << " " << *x+1;
return 0;
}
Выберите один ответ.
e. 002BF7E4 002BF7E8 4
Question 6
Баллов: 1
The address operator & can be applied only to constants and to expressions
Ответ:
False
Question 7
Баллов: 1
Write a single statement that performs the specified task. Assume that floating-point variables number1 and number2 have been declared and that number1 has been initialized to 7.3. Assume that variable ptr is of type char *. Assume that arrays s1 and s2 are each 100-element char arrays that are initialized with string literals. Compare the string in s1 with the string in s2, and print the result.
Выберите один ответ.
c. cout << "strcmp(s1, s2) = " << strcmp(s1, s2) << endl;
Question 8
Баллов: 1
Program components in C++ are called ________ and ________.
Выберите один ответ. a. functions, classes
Question 9
Question 10
Баллов: 1
If I do not want to use return in my function myFunc() what I have to speciafy as return type?
Выберите один ответ.
a. void
Question 12
Баллов: 1
Correct mistake in the statement below:
using namespase std;
Выберите один ответ. a. using namespace std;
Question 13
Баллов: 1
Find the error in the following program segment:
int sum(int n)
{
if (n == 0)
return 0;
else
n + sum(n - 1);
}
Выберите один ответ.
c. int sum(int n)
{
if (n == 0)
return 0;
else
return n + sum(n - 1);
}
Question 14
Баллов: 1
When using parameterized manipulators, the header file ____________ must be included
Выберите один ответ. a. <iomanip>
Question 15
Баллов: 1
Prompt the user to enter an integer. End your prompting message with a colon (followed by a space and leave the cursor positioned after the space.
Выберите один ответ.
c. std::cout << "Enter an integer: ";
Question 16
Баллов: 1
The ________ qualifier is used to declare read-only variables
Выберите один ответ.
a. const
Question 17
Баллов: 1
Find the error in the following program segment. Assume the following declarations and statements:
int *zPtr; // zPtr will reference array z
int *aPtr = 0;
void *sPtr = 0;
int number;
int z[ 5 ] = { 1, 2, 3, 4, 5 };
char s[ 10 ];
cout << strncpy(s, "hello", 5) << endl;
Выберите один ответ.
c. cout << strncpy(s, "hello", 6) << endl;
Question 20
Баллов: 1
Why would a function prototype contain a parameter type declaration such as double &?
Выберите один ответ.
c. This creates a reference parameter of type "reference to double" that enables the function to modify the original variable in the calling function
Question 22
Баллов: 1
Find the error(s) in the following code segment:
switch (n)
{
case 1:
cout << "The number is 1" << endl;
case 2:
cout << "The number is 2" << endl;
break;
default:
cout << "The number is not 1 or 2" << endl;
break;
}
Выберите один ответ.
c. switch (n)
{
case 1:
cout << "The number is 1" << endl;
break;
case 2:
cout << "The number is 2" << endl;
break;
default:
cout << "The number is not 1 or 2" << endl;
break;
}
Question 23
Баллов: 1
Which of the following is the proper keyword to deallocate memory?
Выберите один ответ.
d. delete
Question 24
Баллов: 1
Assuming that nPtr points to the beginning of array numbers (the starting address of the array is at location 1002500 in memory), what address is referenced by nPtr + 8?
Выберите один ответ.
c. The address is 1002500 + 8 * 8 = 1002564
Question 25
Баллов: 1
Write a single statement that performs the specified task. Assume that floating-point variables number1 and number2 have been declared and that number1 has been initialized to 7.3. Assume that variable ptr is of type char *. Assume that arrays s1 and s2 are each 100-element char arrays that are initialized with string literals. Assign the value of the object pointed to by fPtr to variable number2.
Выберите один ответ.
c. number2 = *fPtr;
Question 26
Баллов: 1
Write a single statement that performs the specified task. Assume that floating-point variables number1 and number2 have been declared and that number1 has been initialized to 7.3. Assume that variable ptr is of type char *. Assume that arrays s1 and s2 are each 100-element char arrays that are initialized with string literals. Print the address of number1.
Выберите один ответ.
b. cout << "The address of number1 is " << &number1 << endl;
Question 28
Баллов: 1
Determine the value, true or false, of each of the following Boolean expressions, assuming that the value of the variable count is 0 and the value of the variable limit is 10.
!(count == 12)
Выберите один ответ. a. true
Question 29
Баллов: 1
__________ must be used to initialize constant members of a class
Выберите один ответ.
c. Member initializers
Question 31
Баллов: 1
Which of the following is not valid identifier?
Выберите один ответ.
c. namespace
Question 33
Баллов: 1
Which is not a protection level provided by classes in C++?
Выберите один ответ. a. hidden
Question 34
Баллов: 1
Use a stream manipulator that causes the exponent in scientific notation and the letters in hexadecimal values to print in capital letters
Выберите один ответ.
c. cout << uppercase;
Question 38
Баллов: 1
Write one or more statements that perform the following task for and array called “fractions”. Print all the array elements using a for statement. Define the integer variable i as a control variable for the loop.
Выберите один ответ.
c. for (int i = 0; < arraySize; i++) cout << "fractions[" < i << "] = " << fractions[ i ] << endl;
Question 41
Баллов: 1
The expression (x > y && a < b) is true if either the expression x > y is true or the expression a < b is true
Ответ:
False
Question 42
Баллов: 1
What is the output of the program?
#include <iostream>
using namespace std;
int main() {
int a = 10;
for (a=1; a<81; a*=3)
cout << a << " ";
cout << endl;
return 0;
}
Выберите один ответ.
b. 1 3 9 27
Question 45
Баллов: 1
Calculate the remainder after q is divided by divisor and assign the result to q. Write this statement two different ways.
Выберите по крайней мере один ответ:
b. q %= divisor;
f. q = q % divisor;
Question 46
Баллов: 1
Correct the mistakes:
#include<iostream>
usingnamespace std;
double func();
{
double a = 3.14159;
cout << a << endl;
}
int main()
{
cout << "pi=" << func() << endl;
return 0;
}
Выберите один ответ.
e.
#include <iostream>
using namespace std;
double func()
{
double a = 3.14159;
return a;
}
int main()
{
cout << “pi=” << func() << endl;
return 0;
}
Question 47
Баллов: 1
Empty parentheses following a function name in a function prototype indicate that the function does not require any parameters to perform its task
Ответ:
True
Question 49
Баллов: 1
Which of the following is not valid identifier?
Выберите один ответ.
c. return
Question 50
Баллов: 1
What is the output of the program?
#include <iostream>
using namespace std;
int main() {
int a = 5;
do {
cout << a;
a--;
} while (a>0);
return 0;
}
Выберите один ответ.
d. 54321
Question 51
Баллов: 1
The escape sequence \n, when output with cout and the stream insertion operator, causes the cursor to position to the beginning of the next line on the screen.
Ответ:
True
Question 52
Баллов: 1
Find the error in the following program segment. Assume the following declarations and statements:
int *zPtr; // zPtr will reference array z
int *aPtr = 0;
void *sPtr = 0;
int number;
int z[ 5 ] = { 1, 2, 3, 4, 5 };
// use pointer to get first value of array
number = zPtr;
Выберите один ответ.
c. number = *zPtr;
Question 54
Баллов: 1
The ostream member function ___________ is used to perform unformatted output
Выберите один ответ. a. write
Question 55
Баллов: 1
Write one or more statements that perform the following task for and array called “fractions”. Assign the value 1.667 to array element 9
Выберите один ответ.
b. fractions[ 9 ] = 1.667;
Question 56
Баллов: 1
Find the error in the following program segment and correct the error:
Assume that int a[ 2 ][ 2 ] = { { 1, 2 }, { 3, 4 } };
a[ 1, 1 ] = 5;
Выберите один ответ.
b. a[ 1 ][ 1 ] = 5;
Question 57
Баллов: 1
A pointer is a variable that contains as its value the____________ of another variable
Выберите один ответ. a. address
Question 58
Баллов: 1
Declare a pointer nPtr that points to a variable of type double
Выберите один ответ. a. double *nPtr;
Question 59
Баллов: 1
Which of the following is a two-dimensional array?
Выберите один ответ.
d. int anarray[20][20];
Question 61
Баллов: 1
Give the function header for the following function. Function hypotenuse that takes two double-precision, floating-point arguments, side1 and side2, and returns a double-precision, floating-point result.
Выберите один ответ.
d. double hypotenuse(double side1, double side2)
Question 63
Баллов: 1
Write single C++ statements that determine whether i is less than or equal to y
Выберите один ответ.
c. if (i<=y)
Question 64
Баллов: 1
The cout stream normally is connected to the display screen
Ответ:
True
Question 66
Баллов: 1
Write a single statement that performs the specified task. Assume that floating-point variables number1 and number2 have been declared and that number1 has been initialized to 7.3. Assume that variable ptr is of type char *. Assume that arrays s1 and s2 are each 100-element char arrays that are initialized with string literals. Assign to ptr the location of the first token in s2. The tokens delimiters are commas (,).
Выберите один ответ. a. ptr = strtok(s2, ",");
Question 67
Баллов: 1
Write a single statement that performs the specified task. Assume that floating-point variables number1 and number2 have been declared and that number1 has been initialized to 7.3. Assume that variable ptr is of type char *. Assume that arrays s1 and s2 are each 100-element char arrays that are initialized with string literals. Declare the variable fPtr to be a pointer to an object of type double.
Выберите один ответ.
b. double *fPtr;
Question 68
Баллов: 1
Write a C++ statement or a set of C++ statements to print the integers from 1 to 20 using a while loop and the countervariable x. Assume that the variable x has been declared, but not initialized. Print only 5 integers per line. [Hint: Use the calculation x % 5. When the value of this is 0, print a newline character; otherwise, print a tab character.]
Выберите один ответ. a. x = 1;
while (x <= 20)
{
cout << x;
if (x % 5 == 0)
cout << endl;
else
cout << '\t';
x++;
}
Question 69
Баллов: 1
Determine the value, true or false, of each of the following Boolean expressions, assuming that the value of the variable count is 0 and the value of the variable limit is 10.
(count == 1) && (x < y)
Выберите один ответ.
b. false
Question 70
Баллов: 1
Refer to the fourth element of array numbers using array subscript notation, pointer/offset notation with the array name as the pointer, pointer subscript notation with nPtr and pointer/offset notation with nPtr
Выберите один ответ.
b.
numbers[ 3 ]
*(numbers + 3)
nPtr[ 3 ]
*(nPtr + 3)
Question 71
Баллов: 1
Declare an array of type double called numbers with 10 elements, and initialize the elements to the values 0.0, 1.1, 2.2,..., 9.9.
Assume that the symbolic constant SIZE has been defined as 10.
Выберите один ответ.
b. double numbers[ SIZE ] = { 0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9 };
Question 72
Баллов: 1
Find the error(s) in the following and correct it (them).
Assume the following prototype is declared in class Employee:
int Employee(const char *, const char *);
Выберите один ответ. a. Employee(const char *, const char *);
Question 73
Баллов: 1
Output operations are supported by class ___________.
Выберите один ответ.
c. ostream
Question 78
Баллов: 1
Which of the following accesses a variable in structure b?
Выберите один ответ.
c. b.var;
Question 79
Баллов: 1
All variables must be given a type when they are declared.
Ответ:
True
Question 80
Баллов: 1
Output the address of the variable myString of type char *
Выберите один ответ.
c. cout << static_cast< void * >(myString)
Question 81
Баллов: 1
Every function's body is delimited by left and right braces ({ and }).
Ответ:
True
Question 83
Баллов: 1
Which of the following is not valid identifier?
Выберите один ответ.
b. class
Question 84
Баллов: 1
Which of the following is a correct comment?
Выберите один ответ.
b. /* Comment */
Question 86
Баллов: 1
A C++ program that prints three lines of output must contain three statements using cout and the stream insertion operator.
Ответ:
False
Question 90
Баллов: 1
What value gets printed by the program?
#include <iostream>
int foo(int y);
int foo(int x)
{
return x+1;
}
int main(int argc, char** argv)
{
int x = 3;
int y = 6;
std::cout << foo(x) << std::endl;
return 0;
}
Выберите один ответ.
b. 4
Question 92
Баллов: 1
Which of the following is a properly defined struct?
Выберите один ответ. a. struct a_struct {int a;};
Question 93
Баллов: 1
Find the error in the following program segment. Assume the following declarations and statements:
int *zPtr; // zPtr will reference array z
int *aPtr = 0;
void *sPtr = 0;
int number;
int z[ 5 ] = { 1, 2, 3, 4, 5 };
++zPtr;
Выберите один ответ.
b.
zPtr = z;
++zPtr;
Question 94
Баллов: 1
Find the error in the following program segment. Assume the following declarations and statements:
int *zPtr; // zPtr will reference array z
int *aPtr = 0;
void *sPtr = 0;
int number;
int z[ 5 ] = { 1, 2, 3, 4, 5 };
char s[ 12 ];
strcpy(s, "Welcome Home");
Выберите один ответ. a.
char s[ 13 ];
strcpy(s, "Welcome Home");
Question 96
Баллов: 1
Find the error in the following program segment. Assume the following declarations and statements:
int *zPtr; // zPtr will reference array z
int *aPtr = 0;
void *sPtr = 0;
int number;
int z[ 5 ] = { 1, 2, 3, 4, 5 };
// assign array element 2 (the value 3) to number
number = *zPtr[ 2 ];
Выберите один ответ.
b. number = zPtr[ 2 ];
Question 97
Баллов: 1
Each parameter in a function header should specify both a TYPE and a NAME.
Question 98
Баллов: 1
All variables must be declared before they are used.
Ответ:
True
Question 99
Баллов: 1
What is the output of the program?
#include<iostream>
usingnamespace std;
int main() {
char str[] = "fresh meat";
cout << strlen(str);
return 0;
}
Выберите один ответ.
d. 10
Question 100
Баллов: 1
Determine the value, true or false, of each of the following Boolean expressions, assuming that the value of the variable count is 0 and the value of the variable limit is 10.
!(((count < 10) || (x < y)) && (count >= 0))
Выберите один ответ. a. false
Preparation for Final Exam MCQ Quiz BIG - Попытка 1
Страница: 1 2 3 4 5 6 7 8 9 10 (Далее)
Question 1
Баллов: 1
Find the error in the following program segment. Assume the following declarations and statements:
int *zPtr; // zPtr will reference array z
int *aPtr = 0;
void *sPtr = 0;
int number;
int z[ 5 ] = { 1, 2, 3, 4, 5 };
if (strcmp(string1, string2))
cout << "The strings are equal" << endl;
Выберите один ответ.
a. if (strcmp(string1, string2) == 0)
cout << "The strings are equal" << endl;
Question 2
Баллов: 1
The stream manipulators dec, oct and hex affect only the next integer output operation
Ответ:
False
Question 3
Баллов: 1
Which of the following is the proper keyword to allocate memory?
Выберите один ответ. a. new
Question 4
Баллов: 1
Write a declaration for the following: Double-precision, floating-point variable lastVal that is to retain its value between calls to the function in which it is defined.
Выберите один ответ.
c. static double lastVal;
Question 5
Баллов: 1
$$1 Select the best answer to the output of the program:
#include<iostream>
usingnamespace std;
int main() {
double y = 3;
double *x = &y;
cout << x << " " << x+1 << " " << *x+1;
return 0;
}
Выберите один ответ.
e. 002BF7E4 002BF7E8 4
Question 6
Баллов: 1
The address operator & can be applied only to constants and to expressions
Ответ:
False
Question 7
Баллов: 1
Write a single statement that performs the specified task. Assume that floating-point variables number1 and number2 have been declared and that number1 has been initialized to 7.3. Assume that variable ptr is of type char *. Assume that arrays s1 and s2 are each 100-element char arrays that are initialized with string literals. Compare the string in s1 with the string in s2, and print the result.
Выберите один ответ.
c. cout << "strcmp(s1, s2) = " << strcmp(s1, s2) << endl;
Question 8
Баллов: 1
Program components in C++ are called ________ and ________.
Выберите один ответ. a. functions, classes
Question 9
Question 10
Баллов: 1
If I do not want to use return in my function myFunc() what I have to speciafy as return type?
Выберите один ответ.
a. void
Question 12
Баллов: 1
Correct mistake in the statement below:
using namespase std;
Выберите один ответ. a. using namespace std;
Question 13
Баллов: 1
Find the error in the following program segment:
int sum(int n)
{
if (n == 0)
return 0;
else
n + sum(n - 1);
}
Выберите один ответ.
c. int sum(int n)
{
if (n == 0)
return 0;
else
return n + sum(n - 1);
}
Question 14
Баллов: 1
When using parameterized manipulators, the header file ____________ must be included
Выберите один ответ. a. <iomanip>
Question 15
Баллов: 1
Prompt the user to enter an integer. End your prompting message with a colon (followed by a space and leave the cursor positioned after the space.
Выберите один ответ.
c. std::cout << "Enter an integer: ";
Question 16
Баллов: 1
The ________ qualifier is used to declare read-only variables
Выберите один ответ.
a. const
Question 17
Баллов: 1
Find the error in the following program segment. Assume the following declarations and statements:
int *zPtr; // zPtr will reference array z
int *aPtr = 0;
void *sPtr = 0;
int number;
int z[ 5 ] = { 1, 2, 3, 4, 5 };
char s[ 10 ];
cout << strncpy(s, "hello", 5) << endl;
Выберите один ответ.
c. cout << strncpy(s, "hello", 6) << endl;
Question 20
Баллов: 1
Why would a function prototype contain a parameter type declaration such as double &?
Выберите один ответ.
c. This creates a reference parameter of type "reference to double" that enables the function to modify the original variable in the calling function
Question 22
Баллов: 1
Find the error(s) in the following code segment:
switch (n)
{
case 1:
cout << "The number is 1" << endl;
case 2:
cout << "The number is 2" << endl;
break;
default:
cout << "The number is not 1 or 2" << endl;
break;
}
Выберите один ответ.
c. switch (n)
{
case 1:
cout << "The number is 1" << endl;
break;
case 2:
cout << "The number is 2" << endl;
break;
default:
cout << "The number is not 1 or 2" << endl;
break;
}
Question 23
Баллов: 1
Which of the following is the proper keyword to deallocate memory?
Выберите один ответ.
d. delete
Question 24
Баллов: 1
Assuming that nPtr points to the beginning of array numbers (the starting address of the array is at location 1002500 in memory), what address is referenced by nPtr + 8?
Выберите один ответ.
c. The address is 1002500 + 8 * 8 = 1002564
Question 25
Баллов: 1
Write a single statement that performs the specified task. Assume that floating-point variables number1 and number2 have been declared and that number1 has been initialized to 7.3. Assume that variable ptr is of type char *. Assume that arrays s1 and s2 are each 100-element char arrays that are initialized with string literals. Assign the value of the object pointed to by fPtr to variable number2.
Выберите один ответ.
c. number2 = *fPtr;
Question 26
Баллов: 1
Write a single statement that performs the specified task. Assume that floating-point variables number1 and number2 have been declared and that number1 has been initialized to 7.3. Assume that variable ptr is of type char *. Assume that arrays s1 and s2 are each 100-element char arrays that are initialized with string literals. Print the address of number1.
Выберите один ответ.
b. cout << "The address of number1 is " << &number1 << endl;
Question 28
Баллов: 1
Determine the value, true or false, of each of the following Boolean expressions, assuming that the value of the variable count is 0 and the value of the variable limit is 10.
!(count == 12)
Выберите один ответ. a. true
Question 29
Баллов: 1
__________ must be used to initialize constant members of a class
Выберите один ответ.
c. Member initializers
Question 31
Баллов: 1
Which of the following is not valid identifier?
Выберите один ответ.
c. namespace
Question 33
Баллов: 1
Which is not a protection level provided by classes in C++?
Выберите один ответ. a. hidden
Question 34
Баллов: 1
Use a stream manipulator that causes the exponent in scientific notation and the letters in hexadecimal values to print in capital letters
Выберите один ответ.
c. cout << uppercase;
Question 38
Баллов: 1
Write one or more statements that perform the following task for and array called “fractions”. Print all the array elements using a for statement. Define the integer variable i as a control variable for the loop.
Выберите один ответ.
c. for (int i = 0; < arraySize; i++) cout << "fractions[" < i << "] = " << fractions[ i ] << endl;
Question 41
Баллов: 1
The expression (x > y && a < b) is true if either the expression x > y is true or the expression a < b is true
Ответ:
False
Question 42
Баллов: 1
What is the output of the program?
#include <iostream>
using namespace std;
int main() {
int a = 10;
for (a=1; a<81; a*=3)
cout << a << " ";
cout << endl;
return 0;
}
Выберите один ответ.
b. 1 3 9 27
Question 45
Баллов: 1
Calculate the remainder after q is divided by divisor and assign the result to q. Write this statement two different ways.
Выберите по крайней мере один ответ:
b. q %= divisor;
f. q = q % divisor;
Question 46
Баллов: 1
Correct the mistakes:
#include<iostream>
usingnamespace std;
double func();
{
double a = 3.14159;
cout << a << endl;
}
int main()
{
cout << "pi=" << func() << endl;
return 0;
}
Выберите один ответ.
e.
#include <iostream>
using namespace std;
double func()
{
double a = 3.14159;
return a;
}
int main()
{
cout << “pi=” << func() << endl;
return 0;
}
Question 47
Баллов: 1
Empty parentheses following a function name in a function prototype indicate that the function does not require any parameters to perform its task
Ответ:
True
Question 49
Баллов: 1
Which of the following is not valid identifier?
Выберите один ответ.
c. return
Question 50
Баллов: 1
What is the output of the program?
#include <iostream>
using namespace std;
int main() {
int a = 5;
do {
cout << a;
a--;
} while (a>0);
return 0;
}
Выберите один ответ.
d. 54321
Question 51
Баллов: 1
The escape sequence \n, when output with cout and the stream insertion operator, causes the cursor to position to the beginning of the next line on the screen.
Ответ:
True
Question 52
Баллов: 1
Find the error in the following program segment. Assume the following declarations and statements:
int *zPtr; // zPtr will reference array z
int *aPtr = 0;
void *sPtr = 0;
int number;
int z[ 5 ] = { 1, 2, 3, 4, 5 };
// use pointer to get first value of array
number = zPtr;
Выберите один ответ.
c. number = *zPtr;
Question 54
Баллов: 1
The ostream member function ___________ is used to perform unformatted output
Выберите один ответ. a. write
Question 55
Баллов: 1
Write one or more statements that perform the following task for and array called “fractions”. Assign the value 1.667 to array element 9
Выберите один ответ.
b. fractions[ 9 ] = 1.667;
Question 56
Баллов: 1
Find the error in the following program segment and correct the error:
Assume that int a[ 2 ][ 2 ] = { { 1, 2 }, { 3, 4 } };
a[ 1, 1 ] = 5;
Выберите один ответ.
b. a[ 1 ][ 1 ] = 5;
Question 57
Баллов: 1
A pointer is a variable that contains as its value the____________ of another variable
Выберите один ответ. a. address
Question 58
Баллов: 1
Declare a pointer nPtr that points to a variable of type double
Выберите один ответ. a. double *nPtr;
Question 59
Баллов: 1
Which of the following is a two-dimensional array?
Выберите один ответ.
d. int anarray[20][20];
Question 61
Баллов: 1
Give the function header for the following function. Function hypotenuse that takes two double-precision, floating-point arguments, side1 and side2, and returns a double-precision, floating-point result.
Выберите один ответ.
d. double hypotenuse(double side1, double side2)
Question 63
Баллов: 1
Write single C++ statements that determine whether i is less than or equal to y
Выберите один ответ.
c. if (i<=y)
Question 64
Баллов: 1
The cout stream normally is connected to the display screen
Ответ:
True
Question 66
Баллов: 1
Write a single statement that performs the specified task. Assume that floating-point variables number1 and number2 have been declared and that number1 has been initialized to 7.3. Assume that variable ptr is of type char *. Assume that arrays s1 and s2 are each 100-element char arrays that are initialized with string literals. Assign to ptr the location of the first token in s2. The tokens delimiters are commas (,).
Выберите один ответ. a. ptr = strtok(s2, ",");
Question 67
Баллов: 1
Write a single statement that performs the specified task. Assume that floating-point variables number1 and number2 have been declared and that number1 has been initialized to 7.3. Assume that variable ptr is of type char *. Assume that arrays s1 and s2 are each 100-element char arrays that are initialized with string literals. Declare the variable fPtr to be a pointer to an object of type double.
Выберите один ответ.
b. double *fPtr;
Question 68
Баллов: 1
Write a C++ statement or a set of C++ statements to print the integers from 1 to 20 using a while loop and the countervariable x. Assume that the variable x has been declared, but not initialized. Print only 5 integers per line. [Hint: Use the calculation x % 5. When the value of this is 0, print a newline character; otherwise, print a tab character.]
Выберите один ответ. a. x = 1;
while (x <= 20)
{
cout << x;
if (x % 5 == 0)
cout << endl;
else
cout << '\t';
x++;
}
Question 69
Баллов: 1
Determine the value, true or false, of each of the following Boolean expressions, assuming that the value of the variable count is 0 and the value of the variable limit is 10.
(count == 1) && (x < y)
Выберите один ответ.
b. false
Question 70
Баллов: 1
Refer to the fourth element of array numbers using array subscript notation, pointer/offset notation with the array name as the pointer, pointer subscript notation with nPtr and pointer/offset notation with nPtr
Выберите один ответ.
b.
numbers[ 3 ]
*(numbers + 3)
nPtr[ 3 ]
*(nPtr + 3)
Question 71
Баллов: 1
Declare an array of type double called numbers with 10 elements, and initialize the elements to the values 0.0, 1.1, 2.2,..., 9.9.
Assume that the symbolic constant SIZE has been defined as 10.
Выберите один ответ.
b. double numbers[ SIZE ] = { 0.0, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9 };
Question 72
Баллов: 1
Find the error(s) in the following and correct it (them).
Assume the following prototype is declared in class Employee:
int Employee(const char *, const char *);
Выберите один ответ. a. Employee(const char *, const char *);
Question 73
Баллов: 1
Output operations are supported by class ___________.
Выберите один ответ.
c. ostream
Question 78
Баллов: 1
Which of the following accesses a variable in structure b?
Выберите один ответ.
c. b.var;
Question 79
Баллов: 1
All variables must be given a type when they are declared.
Ответ:
True
Question 80
Баллов: 1
Output the address of the variable myString of type char *
Выберите один ответ.
c. cout << static_cast< void * >(myString)
Question 81
Баллов: 1
Every function's body is delimited by left and right braces ({ and }).
Ответ:
True
Question 83
Баллов: 1
Which of the following is not valid identifier?
Выберите один ответ.
b. class
Question 84
Баллов: 1
Which of the following is a correct comment?
Выберите один ответ.
b. /* Comment */
Question 86
Баллов: 1
A C++ program that prints three lines of output must contain three statements using cout and the stream insertion operator.
Ответ:
False
Question 90
Баллов: 1
What value gets printed by the program?
#include <iostream>
int foo(int y);
int foo(int x)
{
return x+1;
}
int main(int argc, char** argv)
{
int x = 3;
int y = 6;
std::cout << foo(x) << std::endl;
return 0;
}
Выберите один ответ.
b. 4
Question 92
Баллов: 1
Which of the following is a properly defined struct?
Выберите один ответ. a. struct a_struct {int a;};
Question 93
Баллов: 1
Find the error in the following program segment. Assume the following declarations and statements:
int *zPtr; // zPtr will reference array z
int *aPtr = 0;
void *sPtr = 0;
int number;
int z[ 5 ] = { 1, 2, 3, 4, 5 };
++zPtr;
Выберите один ответ.
b.
zPtr = z;
++zPtr;
Question 94
Баллов: 1
Find the error in the following program segment. Assume the following declarations and statements:
int *zPtr; // zPtr will reference array z
int *aPtr = 0;
void *sPtr = 0;
int number;
int z[ 5 ] = { 1, 2, 3, 4, 5 };
char s[ 12 ];
strcpy(s, "Welcome Home");
Выберите один ответ. a.
char s[ 13 ];
strcpy(s, "Welcome Home");
Question 96
Баллов: 1
Find the error in the following program segment. Assume the following declarations and statements:
int *zPtr; // zPtr will reference array z
int *aPtr = 0;
void *sPtr = 0;
int number;
int z[ 5 ] = { 1, 2, 3, 4, 5 };
// assign array element 2 (the value 3) to number
number = *zPtr[ 2 ];
Выберите один ответ.
b. number = zPtr[ 2 ];
Question 97
Баллов: 1
Each parameter in a function header should specify both a TYPE and a NAME.
Question 98
Баллов: 1
All variables must be declared before they are used.
Ответ:
True
Question 99
Баллов: 1
What is the output of the program?
#include<iostream>
usingnamespace std;
int main() {
char str[] = "fresh meat";
cout << strlen(str);
return 0;
}
Выберите один ответ.
d. 10
Question 100
Баллов: 1
Determine the value, true or false, of each of the following Boolean expressions, assuming that the value of the variable count is 0 and the value of the variable limit is 10.
!(((count < 10) || (x < y)) && (count >= 0))
Выберите один ответ. a. false
Question: Every C++ program begins execution at the function:
Main
Question: Every C++ statement ends with a(n):