Last Updated on November 1, 2019 by Admin
CPA Chapter 4 Assessment Online
CPA -- Chapter 4 Assessment
Quiz-summary
0 of 20 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
Information
CPA — Chapter 4 Assessment
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 20 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- Answered
- Review
-
Question 1 of 20
1. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main() {
char t[3][3], *p = (char *)t;
for(int i = 0; i < 9; i++)
*p++ = ‘a’ + i;
cout << t[1][1];
return 0;
}Correct
Incorrect
-
Question 2 of 20
2. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main() {
float *ft[3] = { new float[3], new float[3], new float[3] }, *p;
for(int i = 0; i < 3; i++) {
p = ft[i];
*p = p[1] = *(p + 2) = 10 * i;
}
cout << ft[1][1];
delete [] ft[0];
delete [] ft[1];
delete [] ft[2];
return 0;
}Correct
Incorrect
-
Question 3 of 20
3. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main() {
int *it[3];
for(int i = 0; i < 3; i++) {
it[i] = new int [i + 1];
for(int j = 0; j < i + 1; j++)
it[i][j] = 10 * i + j;
}
cout << it[2][2];
for(int i = 0; i < 3; i++)
delete [] it[i];
return 0;
}Correct
Incorrect
-
Question 4 of 20
4. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main() {
short s = 1;
int i = 2;
long l = 3;
float f = 4.4;
double d = 6.6;
cout << s/i + f/i + d/s;
return 0;
}Correct
Incorrect
-
Question 5 of 20
5. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main() {
short s = 1;
int i = 2;
long l = 3;
float f = 4.4;
double d = 6.6;
cout << s/float(i) + int(f)/i + long(d)/s;
return 0;
}Correct
Incorrect
-
Question 6 of 20
6. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main() {
int i = 2;
float f = 5.8;
f = (int)f;
i = (float) i;
cout << f/i;
return 0;
}Correct
Incorrect
-
Question 7 of 20
7. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main() {
int i = 2;
float f = 4.4;
cout << f % float(i);
return 0;
}Correct
Incorrect
-
Question 8 of 20
8. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;int main() {
int i = 2;
string s = “2”;cout << s + i;
return 0;
}Correct
Incorrect
-
Question 9 of 20
9. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
int main() {
string s = “a”;
cout << s << “b” + “c”;
return 0;
}Correct
Incorrect
-
Question 10 of 20
10. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
int main() {
string s = “a”;
cout << s + “b” + “c”;
return 0;
}Correct
Incorrect
-
Question 11 of 20
11. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
int main() {
string s1 = “ab”;
string s2 = “Abc”;
if(s1 > s2)
cout << “yes”;
else
cout << “NO”;
return 0;
}Correct
Incorrect
-
Question 12 of 20
12. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main() {
string s1 = “Ab”;
string s2 = “Abc”;
cout << s1.compare(s1);
return 0;
}Correct
Incorrect
-
Question 13 of 20
13. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main() {
string s1 = “1”;
string s2 = “12”;
cout << s1.compare(s2);
return 0;
}Correct
Incorrect
-
Question 14 of 20
14. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
int main() {
string s = “0123456789”;
cout << s.substr(3,7).substr(2).substr();
return 0;
}Correct
Incorrect
-
Question 15 of 20
15. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
int main() {
string s = “ABCDEF”;
for(int i = 1; i < s.length(); i += 2)
s[i – 1] = s[i] + ‘a’ – ‘A’;
cout << s;
return 0;
}Correct
Incorrect
-
Question 16 of 20
16. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
int main() {
string s = “AB”;
s.append(s).push_back(s[s.length() – 1]);
cout << s;
return 0;
}Correct
Incorrect
-
Question 17 of 20
17. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
int main() {
string s1 = “aleph”;
string s2 = “alpha”;
string s;
s1.swap(s2);
s2.swap(s);
s.swap(s2);
cout << s2;
return 0;
}Correct
Incorrect
-
Question 18 of 20
18. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
namespace SpaceA {
int A;
}
namespace SpaceB {
int A;
}
using namespace SpaceA, SpaceB;
int main() {
SpaceA::A = SpaceB::A = 1;
std::cout << A + 1;
return 0;
}Correct
Incorrect
-
Question 19 of 20
19. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
namespace S1 {
int A = 1;
}
namespace S2 {
int A = 2 ;
}
int main(void) {
{ using namespace S1;
S2::A = A + 1;
}
{ using namespace S2;
S1::A = A + 1;
}
cout << S1::A << S2::A;
return 0;
}Correct
Incorrect
-
Question 20 of 20
20. Question
1 pointsWhat happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
namespace S {
int A = 1;
}
namespace S {
int B = A + 2 ;
}
int main(void) {
S::A = S::A + 1;
{ using namespace S;
++B;
}
cout << S::B << S::A;
return 0;
}Correct
Incorrect