Biology Forums - Study Force

Science-Related Homework Help Computer Studies Topic started by: Heff on Sep 3, 2017



Title: What will the following code output?int *numbers = new int[5];for (int i = 0; i <= 4; i++) ...
Post by: Heff on Sep 3, 2017
What will the following code output?

   int *numbers = new int[5];

   for (int i = 0; i <= 4; i++)
       *(numbers + i) = i;

   cout << numbers[2] << endl;

A) 2
B) 3
C) 0
D) Five memory addresses
E) 1


Title: Re: What will the following code output?int *numbers = new int[5];for (int i = 0; i <= 4; i++) ...
Post by: bestavinash on Sep 3, 2017
Content hidden