main()
{
int arr[]={12,14,16,18,20}
printf("%u%u";arr+1,&arr+1);
}
//tell me the answer of this question with proper reason..:)//

Answer Posted / rpr

The correct question should be:

main()
{
int arr[]={12,14,16,18,20};
printf("%u%u",arr+1,&arr+1);
}

there are two different notations:
arr+1 and &arr+1;

arr is same as &arr[0] - location of arr[0], first element
arr+1 is same as &arr[1] - location of arr[1]
arr+2 is same as &arr[2] - location of arr[2]
and so on...

here if address of arr is 6524 then address of arr+1 is
6526, address of arr+2 is 6528.. as arr is of int type so a
difference of two.

now about &arr
it represents the location of entire array.
so it will gives address of first element of array.
when 1 is added to it, the size of array is added to it..

example..

if the address of first element,arr[0] is 6524
and the size of array is-
-(no. of elements)*(size of each element)
here 5*2=10

then,
&arr = 6524
&arr+1 = 6524+(1*size of array)=6524+(1*10)=6534
&arr+2 = 6524+(2*10)=6544
and so on..

one more point:
as here notations are behaving in a pointer manner(actually
reference).. you should know pointer saves values in
unsigned int- from 0-65535
..
once the value of pointer reaches 65535, it comes back to 0.

-rpr..ravidasonline@gmail.com

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can one be shocked holding a wire carrying a very large current with a low voltage source?

1555


what is the quantity of cement and sand in 1 sq.m (mortar ratio ) a, 1:4 b, 1:3 c, 1:6

1560


what kind of wood is in high demand in india?

2049


anybody, Please send me the NIC(scientific officer/programmer) model questions papers to this mail id:imtiyazahamed14@gmail.com

1439


what are the various technique used for inter process communication?

1648






I'm currently placed in Lahore Pakistan. where can i do Microsoft certification. let me know the best place to do.?

1382


how u test the idoc in inbound and outbound?

1580


how to implement spiral model on railway reservation?.

2612


how do we get persistent databases?

1533


What kind of question can be asked at the time of Interview for State Bank Of India Clerical Interview

1622


What is mean by the error LVALUE REQUIRED in C language

2405


What is the meaning of "co relation" and what is the value of "co relation" in the performance testing environment.

1554


can any give an exact example about, resolving the sql errorcode -305

1458


can u perform addition of two octal numbers using java?

4954


what should i say in the interview if interviewer asks me "why did you choose IT instead of your core group?"

1571