1.

Consider the following array initialisation, int ar[5]={-2,-4,-6,2,4}; If first element of array is stored at 2050 and size of int is 4, nd the output of the following.1. cout<< *ar+*(ar+3); 2. cout<< ar+*(ar+4);

Answer»

1. 

*ar = -2

*(ar + 3) = 2 (fourth element) 

Hence *ar + *(ar + 3) = -2 + 2 = 0 

Hence output is 0

2. 

Here ar = 2050 (starting address) 

and * (ar + 4) 

= *(2050 + 4*4) 

= *(2050+16) 

= *(2066) 

= 4 (fth element) 

Hence ar + * (ar + 4) 

= 2050 + 4 

= 2054



Discussion

No Comment Found