Chapter 1 Assessment – CPA Pragraming Essentials C++
-
1. Question
Which of the following strings is a proper integer number (in the “C++” language sense)? -
2. Question
What is the value of the following literal?
010
-
3. Question
What is the value of the following literal?
X10
-
4. Question
What is the value of the following literal?
018
-
5. Question
What is the value of the following literal?
0x1A
-
6. Question
Which of the following strings represents a valid variable name?
-
7. Question
Which of the following strings does not represent a valid variable name? -
8. Question
Which of the following strings is a proper floating-point number (in the “C++” language sense)? -
9. Question
What is the value of the following literal?
0E1
-
10. Question
What is the value of the following literal?
-1e-1
-
11. Question
What is the value of the i variable?
float x = 1.0 / 4.0;
int i = x; -
12. Question
What is the value of the x variable?
float x = 1. / 2. + 2. / 4.;
-
13. Question
What is the value of the k variable?
int k = 1 % 2 + 4 % 2;
-
14. Question
What is the value of the k variable?
int i = 1;
int j = ++i;
int k = j++; -
15. Question
What is the final value of the k variable?
int i = 3, j, k;
if(i > 0) j = 2 + i * i;
if(i <= 0) j = 2 * i – 1;
if(j >= 0) k = j % i + 2;
if(j < 0) k = i % j + 2;
if(k < 0) k = k % i % j;
if(k >= 0) k = j % i % k; -
16. Question
What is the final value of the k variable?
int i = 3, j = 2, k = -1;
if(i > 0) {
if(j <= 0) {
if(k < 0)
k++;
if(k <= 0)
k–;
}
if(j > 0)
i++;
}
if(i <= 0)
j++;
k = i + j + k; -
17. Question
What is the output of the following snippet?
int i = 3, j = ++i, k = ++i;
cout << k << j << i; -
18. Question
What is the output of the following snippet if a digit 5 followed by Enter is entered through the keyboard?
int i = 3, j = ++i, k = ++i;
cin >> i;
cout << k + i << j – i << i * i; -
19. Question
What is the output of the following snippet if a digit 8 followed by Enter is entered through from the keyboard?
int i;
cin >> i;
cout << i << hex << i + i << oct << i; -
20. Question
What is the output of the following snippet if a string 2.5 followed by Enter is entered through the keyboard?
float x;
cin >> x;
cout << scientific << “x”;