Question: Fix the code so it will compile and run without crashing. Should be 3 problems and additions and/or modifications you'll need to complete. #include using

Fix the code so it will compile and run without crashing.

Should be 3 problems and additions and/or modifications you'll need to complete.

#include using namespace std; int main(int argc, char **args) { int *ptr, *current; const int SIZE = 5; ptr = new int[SIZE]; int value[SIZE]; ptr = current = value; for (int i = 0; i <= SIZE; i++) value[i] = i * 2; for (int i = 0; i < SIZE; i++) { cout << *ptr << endl; ptr++; } cout << *(--ptr) << endl; for (int i = 0; i < SIZE; i++) { cout << *current << endl; current++; } cout << *(ptr) << endl; cout << *(--current) << endl; for (int i = 0; i <= SIZE; i++) *(ptr++) = i * 2; for (int i = 0; ptr <= &value[SIZE - 1]; ptr += 1) *ptr = i++ * 2; ptr--; cout << "The value where pointer 'ptr' pointing to is: " << *ptr << endl; return 0; }

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!