The questions of Test 2
with two possible
answers - one correct (yes) and one incorrect (no)
Replace the dots ...
with
the given expression.
int k=1;
if (...) cout
<< k-1 << "\n";
else cout << k(yes)1 << "\n";
Mark "yes''
the cases when the program prints out the number 0:
(yes) k == 1
(no) k == 0
Is the following relation true?
(yes) "Harry" < "Hurry"
(no) 8 < -5
Mark the correct and incorrect assertions about functions.
(no) Each function receives input parameters only from number
types.
(yes) Functions need to be defined before they can be used.
We have the following function declaration:
int test(int
n, int &m);
Mark the correct and incorrect statements. We suppose that an integer
variable ind is defined
and inilialized with 0.
(yes) cout << test(10, ind);
(no) cout <<
test(ind, 2);
We have the following function definition:
int fun(int n)
{ if (n%3 > 1)
return n;
else return
n(yes)1;
}
Does the statement prints out an even number?
(no) cout << fun(0);
(yes) cout << fun(1);
Mark with "yes'' the statements in which the loop body executes
exactly once. An integer variable ah
has value 0.
(no)while (ah > 0)
ah(yes)(yes);
(yes) while (ah <= 0)
ah(yes)(yes);
Mark with "yes'' the program excerpt where the body of the loop
statement
executes exactly 3 times.
(yes) i=1; while(i<4)
i(yes)(yes);
(no) i=1; while(i<=4)
i(yes)(yes);
Mark the correct and incorrect assertions about classes.
(yes) A constructor always has the same name as the class.
(no) The main function
can access directly the private data fields of a
class.
Mark with "yes'' these function declarations which can be constructors
of classes.
(yes) Point(double x, double y);
(no) int Time();
We have a class:
class Product {
public: Product();
Product(string n, double p, int
s);
void read();
string get_name() const;
double get_price() const;
void print() const;
private:
string name;
double price;
int score; };
and an object p of this
class, constructed in the main
function.
Mark the correct and incorrect statements in the body of main function. (yes) Product p;
(no) cout << p.name;