The questions of Final Test
with
two model
answers - one correct (yes) and one incorrect (no)
Mark the
syntax correct/incorrect definition
statements.
(yes) int dimes = 3;
(no) pennies = 1;
Mark the arithmetic
expressions which have double type
of
the
result.
Assume
that the following definitions are given:
const int n = 66;
double zen = 6.6;
(yes) zen - n/3
(no) n%3 + 12
We have
the following variable definitions:
int ten = 10;
int nine = 9;
int eight = 8;
Calculate the expression and write the result.
(yes) ten / nine
<= 1
(no) ten / nine / 2
> 0
Is the following relation
true? For comparing the characters use ASCII table.
(yes)"Harry" < "Hurry"
(no) 8 < -5
We have the following
function declaration:
int
verb(double& x, const double y);
Mark the correct/incorrect statements. We suppose that a double
variable mode is defined
and initialized with 0.0.
(yes) cout << verb(mode,
2.5);
(no) cout << verb(0, 2.5);
We have the
following
function definition:
int h(int n, int m)
{
if (n > 10 && m < 10) return n / m;
return n * m;
}
Does the statement prints out a number, which is greater than 10?
(yes) cout << h(2, 20);
(no) cout << h(12, 2);
Mark with "yes" infinite
loops and with "no" finite
loops. The value of the integer variable hoh is obtained from
the input stream.
(yes) do hoh++; while (hoh != 0
|| hoh == 0);
(no) do hoh--; while(hoh >
100);
Mark with "yes" the
statements in which the loop body
executes exactly once. The
integer variable pink has
value
1.
(yes) while(pink == 1) pink--;
(no) while(false) pink++;
We have the following
variable definitions:
string num = "2010";
const string ABC = "abc";
Mark the syntax correct/incorrect statements.
(yes) cout <<
num.substr(0,2);
(no) cout << length(ABC);
Mark the syntax
correct/incorrect loop statements.
Variables k and i have int
type.
(yes) for(i = -1; i < 4; t++)
cout << i;
(no) for{k = 1; k < 10; k++}
cout << k*i;
Mark with "yes" the
equivalent
logical expressions (1) and (2).
(yes) (1)
mouse == "Jerry" && cat
!= "Sylvester"
(2) ! (mouse != "Jerry" || cat ==
"Sylvester")
(no)
(1) mouse == "Jerry" && cat !=
"Tom"
(2) ! (mouse != "Jerry" && cat ==
"Tom")
Mark the
correct/incorrect
assertions about vectors.
(yes)
A vector is a collection of data items of the same type.
(no)
The statement vector<int> b[2];
defines a vector of two elements.
We have a vector and values of
its elements:
vector<int> sol(2);
sol[0] = 1;
sol[1] = 3;
Mark correct/incorrect statements.
(yes) cout << sol.size();
(no) cin >> sol.size();
We have the following main function:
int main()
{ int
count = 0;
string word;
while (cin >> word) count++;
cout << count << " words." << endl;
return 0;
}
Is the assertion true?
(yes) count is a variable
name.
(no) int count = 0; is
assignment statement.
Mark the
correct/incorrect
assertions about arrays.
(yes)
An array element can be used like any variable.
(no)
An array can be defined without a size parameter.