Страница: (Назад) 1 2 3 4 5 6 7 8 9 10 (Далее)
Question21
Баллов: 1
What gets printed for the value of z?
#include <iostream>
struct Foo
{
Foo(int n): x(n++), y(n++), z(n++) {}
int x;
int y;
int z;
};
int main(int argc, char** argv)
{
Foo f(3);
std::cout << "x: " << f.x << std::endl;
std::cout << "y: " << f.y << std::endl;
std::cout << "z: " << f.z << std::endl;
return 0;
}
Выберите один ответ.
a. code is ill-formed | ||
b. 4 | ||
c. 5 | ||
d. 3 |
Question22
Баллов: 1
Find the error(s) in the following and correct it (them).
The following is a partial definition of class Time:
class Time{
public:
// function prototypes
private:
int hour = 0;
int minute = 0;
int second = 0;
}; // end class Time
Выберите один ответ.
a. class Time { public: // function prototypes private: hour = 0; minute = 0; second = 0; }; // end class Time | ||
b. class Time{ public: // function prototypes Time (int my_hour, int my_minute, int my_second) { hour=my_hour; minute=my_minute; second=my_second; } private: int hour; int minute; int second; }; // end class Time | ||
c. no errors |
Question23
Баллов: 1
All programs can be written in terms of three types of control structures:
Sequence, selection and repetition.
Question24
Баллов: 1
Find the error(s) in the following code segment. The following code should print the values 1 to 10:
n = 1;
while (n < 10)
cout << n++ << endl;
Выберите один ответ.
a. n = 1; while (n <=11) cout << n++ << endl; | ||
b. n = 1; while (n < 11) cout << n++ << endl; | ||
c. n = 1; while (n <= 10) cout << ++n << endl; |
Question25
|
|
Баллов: 1
All arguments to function calls in C++ are passed by value
Ответ:
True+False
Question26
Баллов: 1
What is the output of the program?
#include<iostream>
usingnamespace std;
int main() {
int a = 1;
do {
a+=1;
cout << a;
} while (a<5);
return 0;
}
Выберите один ответ.
a. 1234 | ||
b. 23456 | ||
c. 2345 | ||
d. 12345 | ||
e. 123456 |
Question27
Баллов: 1
Predecrement the variable x by 1, then subtract it from the variable total
Выберите один ответ.
a. total = --x; | ||
b. total -= x--; | ||
c. total -= ++x; | ||
+ | d. total -= --x; | |
e. total -= x++-; |
Question28
Баллов: 1
A function that calls itself either directly or indirectly (i.e., through another function) is a (n) ________ function
Выберите один ответ.
+ | a. recursive | |
b. special | ||
c. not sure | ||
d. repetition | ||
e. loop |
Question29
Баллов: 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. int Employee(const char *, const char *); | ||
+ | b. Employee(const char *, const char *); | |
c. Employee(const char, const char); |
Question30
Баллов: 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 the value pointed to by sPtr to number
number = *sPtr;
Выберите один ответ.
a. number = *static_cast< int * >(sPtr); | ||
b. number = sPtr; | ||
c. number = *sPtr; |
Страница: (Назад) 1 2 3 4 5 6 7 8 9 10 (Далее)