100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Exam (elaborations)

CPA AnswerSheet Programming Essentials in C++ Chapter 4 Assessment

Rating
-
Sold
-
Pages
9
Grade
A+
Uploaded on
02-09-2022
Written in
2021/2022

CPA AnswerSheet Programming Essentials in C++ Chapter 4 Assessment

Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Course

Document information

Uploaded on
September 2, 2022
Number of pages
9
Written in
2021/2022
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

CPA Chapter 4 Assessment Answers 100%
1. What 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;
}

 It prints g
 It prints c
 Compilation fails
 It prints e
2. What 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;
}

 It prints 20
 It prints 30
 It prints 10
 Compilation fails

, 3. What 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;
}

 It prints 33
 It prints 22
 It prints 11
 Compilation fails
4. What 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;
}

 It prints 4.4
 Compilation fails
 It prints 6.6
 It prints 8.8
5. What happens when you attempt to compile and run the
following code?
$5.49
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
arviemontemayor

Also available in package deal

Get to know the seller

Seller avatar
arviemontemayor AMACC
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
3 year
Number of followers
0
Documents
39
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions