Adobe Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




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

if you are printing 5 times using a for loop then output will be same.

if you are printing 5 times by running program 5 times then o/p will be different as program reserves memory at different location when you run.

- Livin D'cruz September 23, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

can you explain why "program reserves memory at different location when you run" . The segments are at same place in memory , so shouldn't the variables be stored at same location ?

- !@# September 23, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 2 vote

The o/p will be the as many times as we run
its prints the address of the global variable

- kokku2chiranjeevi September 22, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If you are compiling the code as "Position Independent," then the base address of the segments can be randomized (safety feature). (Shared libraries, for example, will use this feature since they're mapped into the address space of the executable.) This will give different addresses for the variable. However, you can compile turning this feature off, forcing variables to use the same address.

#include <stdio.h>

int a;
int main(int argc, char **argv)
{
	printf("%u\n", (unsigned int)&a);
}

Example using GCC:

$ gcc -o memtest memtest.c
$ ./memtest
260116504
$ ./memtest
122437656
$ gcc -fno-pie -o memtest memtest.c
$ ./memtest
4120
$ ./memtest
4120

- Anonymous September 23, 2014 | 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