NetApp Interview Question for Software Engineer / Developers






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

4 (Sizeof int)

The only reason for having datatypes for pointers. Becuase all pointers (Any data type) can hold address of memory which is always unsigned long/int. Then why to have data types for pointers? How manipulations on particular pointers has to be done.........for this reason data typoes are required for pointers.

- mlakshmanarao August 03, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

There is an implicit conversion from pointer to int.
"A pointer may be converted to an integral type. The size of integer required and the result are implementation defined. If the space provided is not long enough, the behavior is undefined."
If sizeof(int*) > sizeof(int), you have undefined behavior. If you have 64 bit pointers and 32 bit ints, on a big-endian machine the (undefined) result most likely would be 0.
But even if they are equal, the result is implementation defined (think segmented memory architecture).

- Anonymous July 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int *p=0;

It means that p is a pointer to integer and has a value of 0.That means p is a pointer that points to the location 0 in the memory.Now when you increment the value of p it will increase by the value of its type which is 4(for integer pointer).

So the printf statement will o/p 4.

- KK July 21, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

what about int *p=-1;

Do we have negative memory location?

- Devesh February 29, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

good

- laks August 13, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

what is d differnce b/w <1> *p=0 <2> i=0; *p=&i

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

int main()
{
int *p,i=0;
p=&i;
printf("%u",p);
}

can u explain m d differnce b/w the code given and code given b m,

- suresh May 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

p=&i assigns p the address of i. In other words now p is pointing to address of i.
Now printing p prints the address where it is pointing to. If you want to see the value in the address that p is pointing to then p has to be de-referenced i.e printf("%u",*p);

- Siva October 30, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Checked it on codepad ...

prints the value assigned + 4 in general ....
Ex: int *p = -1, prints 3, int *p = -20 prints -16 and so on ....

- Vikas May 28, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Doesn't it give a run time error as it is not returning any data but main has int as the return type?

- PP January 28, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

It should print sizeof(int).

- socrates July 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

supercoool

- Anonymous July 12, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

It will not print size . It will be converted into int and print 4. if we do printf("%d",p+2);
it will print 8

- DNV July 21, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

It will be increased by size of type

- DNV July 21, 2011 | 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