Show what the cout statement would be if it used pointer not
Show what the cout statement would be if it used pointer notation instead
void main()
{
const int size=5;
int numbers[SIZE]={1,2,3,4,5};
int count;
for(count=0; count<SIZE; count++)
{
cout<<numbers[count]<<endl;
}
}
Solution
Answer:
I believe it is :
cout<<*numbers + count*4 <<endl;
Numbers is an array. So it does not hold the value. It only stores the address where the value is stored.
But *number will go to that address and will read the value. And every integer is 4 bytes ,
so, to get the next value of the array, you have to go to the address and more four bytes to get the next value. And move four bytes again to get the 3rd value.So I have +4*count.
![Show what the cout statement would be if it used pointer notation instead void main() { const int size=5; int numbers[SIZE]={1,2,3,4,5}; int count; for(count=0; Show what the cout statement would be if it used pointer notation instead void main() { const int size=5; int numbers[SIZE]={1,2,3,4,5}; int count; for(count=0;](/WebImages/44/show-what-the-cout-statement-would-be-if-it-used-pointer-not-1137195-1761608976-0.webp)