Question: 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

 

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

1 Expert Approved Answer
Step: 1 Unlock

Here are the identified syntax and logical errors in the provided C code a 1 The pointer myPtr is no... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!