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

2 What is the output produced when the following code iscompiled and executed? #

ID: 3613281 • Letter: 2

Question

2 What is the output produced when the following code iscompiled
and executed?

#include <iostream>
using namespace std; //introduces namespace std


int main()

{
int *p1, *p2, x=3;
p1 = new int;
*p1 = x * 20;
p2 = p1;
cout << "A: " << x * *p1 << " " << *p2<< endl;
*p2 = 30;
cout << "B: " << x * *p1 << " " << *p2<< endl;
p1 = new int;
*p1 = 40;
cout << "C: " << x * *p1 << " " << *p2<< endl;
return 0;


}

2






a) A: 180 60

B: 30 90
C: 120 30
b) A: 180 60

B: 90 30
C: 30 120
c) A: 180 60

B: 90 30
C: 120 30
d) No output will be generated because the code will notcompile

e) No output will be generated because the code will cause the
program to end abnormally.

Explanation / Answer

please rate - thanks 2 What is the output produced when the following code iscompiled and executed? #include using namespace std; //introduces namespace std int main() { int *p1, *p2, x=3; p1 = new int; *p1 = x *20;             //*p1=3*20=60 p2 =p1;                    //p2=p1 cout
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