Question: Task 2 , debug the code - - 1 2 MarksThe following code segment fails to initialize the array elements to 1 . State the

Task 2, debug the code --12 MarksThe following code segment fails to initialize the array elements to 1. State the usage of the keyword auto. Rewrite the code segment so that it could work.int *ptr = new int[7]; for(auto& x : ptr)x =1;Objectives1. re-correct the code and make it work by using three different ways. 2. explain the reason why the code contains problems .3. explain how your proposed different approaches solve this problem.submit your code into debug.cpp, subtask2 and subtask3 should be included in comments of your debug.cpp

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!