Tuesday, March 12, 2013

Pointer Arithmetic Interview Puzzle at Job Puzzles.Com


Pointer Arithmetic Question for technical interviews.
I am also giving solution to this, but it is adviced to see the solution only after trying for sometime.

Question: What will be the output of following code and how.

void main()
{
int *p,*q;
p=(int *)40;
q=(int *)60;
printf("%d\n",q-p);
}


Answer:
It is 6-40=20
and then 20/2 =10
Think How!!

1 comment:

  1. Rousing and particularly significant, significantly recommended for all bloggers out there.
    Resumeyard

    ReplyDelete