Answered step by step
Verified Expert Solution
Question
1 Approved Answer
28. In the C++ code given in (a) and (b), find any syntax or logical errors. (8, 11) a. int *myPtr = new int;
28. In the C++ code given in (a) and (b), find any syntax or logical errors. (8, 11) a. int *myPtr = new int; int *yourPtr; *myPtr = 5; yourPtr myPtr; //Line 1 //Line 2 //Line 3 //Line 4 cout < < *your Ptr < < endl; //Line 5 delete yourPtr; cout < < *myPtr < < endl; b. int *myListPtr = new int[10]; //Line 6 //Line 7 //Line 1 int yourListPtr; //Line 2 for (int i = 0; i < 10; i++) //Line 3 myListPtr [1] 1(11); //Line 4 yourListPtr = myListPtr; //Line 5 delete [] yourListPtr; for (int i = 0; i < 10; i++) cout < < myListPtr [1] < < " "; //Line 8 //Line 6 //Line 7 cout < < endl; //Line 9
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Here are the identified syntax and logical errors in the provided C code a 1 The pointer myPtr is no...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started