Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ basic coding. 2 easy quick code questions...need ASAP. Thanks! 1. What is th

ID: 3566336 • Letter: C

Question

C++ basic coding. 2 easy quick code questions...need ASAP. Thanks!

1. What is the output of the following C++ code?

int*tempList;

int num = 3;

tempList - new int [7];

tempList[6] = 4;

for (int j = 5; j >= 0; j--)

tempList[j] = tempList [j + 1] + j * num;

for (int j = 0; j < 7; j++)

cout << tempList [j] << " ";

cout << endl;

2. What is wrong with the following code?

double *p;

p = new double [5];

for (int i = 0; i < 5; i++)

p [i] = pow (i, 2.0);

for (auto x: p)

cout << x << " ";

cout << endl;

Thank you!

Explanation / Answer

1.

49 49 46 40 31 19 4

2.

for(const auto &x: p) instead of for(auto x: p)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote