NetApp Interview Question for Software Engineer / Developers






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

Suppose that alignment is 4 bytes(word size).

struct A{
char c; => 1 byte + 3 bytes alignment
int a; => 4 bytes
char d; => 1 byte + 3 bytes alignment
};

"A" total: 12 bytes

struct B{
int a; => 4 bytes
char c; => 1 byte
char d; => 1 byte + 2 bytes alignment
};

"B" total: 8 bytes

- Maxim Stepanenko March 09, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

On my machine x86 disassembled code looks like:

....
.align 4
....

- Maxim Stepanenko March 09, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

byte padding will be done by compiler to reduce number of machine cycles to read. if the integers are stored in the address which is divisible by its size (say 4) then only cpu can read whole 4 bytes in a single cycle other wise cpu machine cycles will be more heance byte padding will be done.

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

This should print 12

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

can ny1 please xplain wat is allignment??

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

Say we don't have pad, then say c start at address 0, a will start at address 1 ,d will start at address 5, so when we want to read a, we need read an integer from address 0 first for the _first_ 3 bytes of a, then we need read from address 4 to read the last byte;

Datatype misallignment error might happen due to this.

- Charles December 31, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

@Anonymous good explanation man

- User November 19, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

can ny1 xplain me wat allignment means???

- rockstar June 03, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

suppose an int needs to be assigned memory it can only start from an address%4 = 0, so if char is assigned above only 1byte is used and int addressing can start only after 3 extra bytes

- legolas February 27, 2013 | 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