Adobe Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
3
of 5 vote

Shouldn't.
tmp is int* so tmp+1 moves the pointer 4 bytes forward. tmp+=sizeof(int) == tmp+=4 this pushes tmp 16 bytes forwards so nothing meaningful but shit is outputing.

- Zhen January 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

output will be
4 garbage values....

- keshav January 23, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Garbage value should be displayed.
for tmp+=1, 20 will be displayed.
so for tmp+=4,garbage value is displayed.
I am just rephrasing zhen's word

- crypticcoder February 02, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

You guys are just plain wrong.

every array's name is a pointer to its first element.
incrementing the array by the size of the value in the array increments to its next element.

So the answer will be 20,30,40, GarbageValue
since it increments 4 times

- PrateekS. August 03, 2014 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Since a pointer internally also increments according to the type of the variable it is pointing to, so shouldnt the output be - 20 30 40 garbage ?

Plz tell me if i'm wrong

- Tara January 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

since we are doing tmp+=sizeof(int);
hence if size of int is 2 bytes on a machine then temp will point to value 30 (2 index ahead from oth index) of array and we will get 30 after that it will print garbage as it will be pointing out of array boundaries...

- AJIT January 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

did you try to run this code on any compiler ?

- Tara January 24, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

yes i have run this and i was getting 30 0 0 0

- ajit January 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The output will definitely be four garbage values

- Anonymous January 25, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

yes, its giving 4 garbage values

- Anonymous February 23, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

This might even crash because its trying to access invalid memory location.

- Nitesh February 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

On all typical machines integer occupies 4 bytes, so this code will definitely print 4 garbage values. Please don't use outdated compilers like Turbo C. Use either VC++ or GCC compilers or their equivalents.

- Ravi February 17, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

codepad[dot]org/HpI3dOSQ

- Ajeet March 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

this will crash

- Anonymous March 17, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Output 30 0 0 0

- ajitpec January 22, 2011 | Flag Reply


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