Answered step by step
Verified Expert Solution
Link Copied!

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions