VMWare Inc Interview Question for Software Engineer / Developers






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

Actual code is this--->

int main()
{
int i;
void checkStack(int*);
checkStack(&i);
return 0;
}
void checkStack(int *j)
{
int k;
if(&k>j) printf("Stack is growing UP");
else printf("Stack is growing DOWN");
}

So we are actually checking the local variable address which should be in Stack;

- Punch July 20, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

correct.

- Anon August 04, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

right ans.!

- aditya rajhans October 08, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Refer the manual? No C required, plain or with fruit. Silly question.

Anyway, typical answer is to declare local variables and compare the address values.

- Anonymous May 14, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Has anyone really run these testing programs and found that the stack from higher memory to lower? Then please let us know the platform that was used to test.

- SS September 25, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

it wont be accurate in case we declar two local variable because compiler may try to optimize the code, so the behavior of local variable is undefined.

so just call a function & check as said by - Punch

- vijaymukilan July 17, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <iostream>
using namespace std;

int main (int argc, char * const argv[])
{
int a = 1;
int b = 2;
cout << (&a - &b) << endl;

getchar();
return 0;
}

- D May 14, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Declaring two variables and finding the difference does not tell whether stack grows up or down.
Bcoz, both variable will be stored in the same stack frame.

So, Declare 1 variable in one funtion and another variable in another fucntion and find the difference of those address.
This will work, bcoz for each function there will be a separate stack created.

- Anonymous November 01, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

int main()
{

char a[] = {'a','b'};

if((&a[0] -&a[1])>0)
	printf("\nDown");
else
	printf("\nUp");

return 0;

}

- Zack May 14, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

compare the addr of an array is wrong. No matter go down or up, &array[0] is less than &array[1].

- chenming831@hotmail.com May 16, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

what does stack growing up or down mean....

- Anonymous May 15, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

local variable are stored in stack. The stack is a common space used by all function for its manipulation once its control move out the values are pop out.

- vijaymukilan July 17, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

void testack(void);
int main(void)
{
int a;
printf("\n the address : %p", &a);
testack();
}
void testack(void)
{
int b;
printf("\n the address of b : %p", &b);
}
comparing the address of "a" and "b" we can say whether it is a growing up or growing down stack..

- root.next May 17, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int *arr[5]={0,0,0,0,0};
static int i=0;

void testStackAdd()
{
int local;
arr[i]=&local;
cout<<std::ios::hex<<arr[i++]<<endl;
if(i<5)
testStackAdd();
}

void main()
{
int ii;
cout<<&ii<<endl<<endl;
testStackAdd();
cout<<endl;
cout<<std::ios::hex<<&i;
getchar();
}

- Crime_Master_GoGo November 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int *arr[5]={0,0,0,0,0};
static int i=0;

void testStackAdd()
{
	int local;
	arr[i]=&local;	
	cout<<std::ios::hex<<arr[i++]<<endl;
	if(i<5)
	testStackAdd();
}

void main()
{
	int ii;
	cout<<&ii<<endl<<endl;	
	testStackAdd();
	cout<<endl;
	cout<<std::ios::hex<<&i;			
	getchar();
}

- Anonymous November 06, 2010 | 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