| (a) | (x > y) && (y <= 3) |
| (b) | (x > y) || (y <= 3) |
| (c) | (x < y) || (y >= 3) |
| (d) | (x <= y) || (y > 3) |
| (e) | (x <= y) && (y > 3) |
p || (n < 3)
| (a) | if p is true, then n < 3 will not be evaluated |
| (b) | if p is false, then n < 3 will not be evaluated |
| (c) | if p is true, then n < 3 will be evaluated |
| (d) | none of the above |
for (i = 0; i < 12; i++)
cout << i + 1 << endl;
| (a) | the numbers 0 through 12 (including 0 and 12) |
| (b) | the numbers 1 through 12 (including 1 and 12) |
| (c) | the numbers 0 through 11 (including 0 and 11) |
| (d) | the numbers 1 through 11 (including 1 and 11) |
int num = 10;
int sum;
Which of the following code segments correctly computes the sum of the first
10 multiples of 5 (i.e., 5, 10, ..., 50)?
| (a) |
sum = 5;
while (num > 1)
{
sum += sum;
num--;
}
|
(d) |
sum = 0;
while (num >= 0)
{
num--;
sum += 5 * num;
}
|
| (b) |
sum = 5;
while (num > 0)
{
sum += sum;
num--;
}
|
(e) |
sum = 0;
while (num > 0)
{
sum += 5 * num;
num--;
}
|
| (c) |
sum = 0;
while (num > 0)
{
num--;
sum += 5 * num;
}
|