Interview Question


Country: India




Comment hidden because of low score. Click to expand.
1
of 1 vote

should be (Address of x - Address of y)/sizeof(int)., not necessarily be 1.

- alex March 27, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yes. It should be one if these variables are array elements

- chinni April 14, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yes. It should be one if these variables are array elements

- chinni April 14, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Yes. It should be one if these variables are array elements

- chinni April 14, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

If they are auto in the same function the answer should be 4. The stack grows from higher to lower, so p - q should give 4 bytes difference.i.e-, sizeof(int)

- Anonymous March 24, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

correction. The answer is one.

- Anonymous March 25, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

out put c=1;
it is 1 why?

- Anonymous March 25, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

it should be 4 the difference of two int pointers but its out put c=1 why?

- Anonymous March 25, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

because these value stored in stack .so difference of address is 4 bytes (in 32 bit compiler) .after subtraction it will give 4 and devided it by 4 (4/4) it always give 1
so answer always 1.

- sachendra May 30, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Difference of two pointers gives an integer value. It gives (Address of x - Address of y)/sizeof(int).

- Rama Chandra Paital March 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Difference of two pointers of some type "TYPE' gives the number of block of the type 'TYPE' b/w the two addresses. That's why the output will be 1.

- -- March 26, 2012 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More