Consider the following program include using namespace std i

Consider the following program: #include using namespace std; int main () {float *a[10];//array of float pointers int i = 1; for (auto &p;:a) {p = new float; *p = i i++;} for (int j = 1; j

Solution


Here, first we are creating array of 10 float pointers and they are pointing to memory storing 1 to 10. [Line 5-11]

After that, we are deleting all memory pointed by all pointers[Line 12-15] and assigning null pointers to all

Then from Line 16-18, we are printing all non null pointers, but we have deletd all and they all are pointing to null, so it will not print anything

From line 20-24, we again pointing each pointer to memory storing from 1 to 10

FRom line 25-27, we are printing all pointers.

Output: 1 2 3 4 5 6 7 8 9 10

 Consider the following program: #include using namespace std; int main () {float *a[10];//array of float pointers int i = 1; for (auto &p;:a) {p = new floa

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site