## Dover Organization Interview Question for Developer Program Engineers

• 0

Country: India
Interview Type: In-Person

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

1. x=13,y=21;
3. **p points the value at the address which is stored at address p and &(*p) points address p

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

1. x=14,y=21
3.**P points to the location that *p points...
and &(*p) gives the address of value that p points...

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

1. x=13, y=21;

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

x=13, y=21

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

x=11,
y=20

Comment hidden because of low score. Click to expand.
0

int x, y;
x = 5; y = 6;
x = y++ + x++; // x is 12 (5+6 = 11 and then x is incremented to 12 and y to 7)
// y = 7 now and x =12
y = ++y + ++x;// 8 + 13
// x = 12, y = 20

Comment hidden because of low score. Click to expand.
0

int x, y;
x = 5; y = 6;
x = y++ + x++; // x is 12 (5+6 = 11 and then x is incremented to 12 and y to 7)
// y = 7 now and x =12
y = ++y + ++x;// 8 + 13
// x = 13, y = 21

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

X= 12,
Y = 20

int x, y;
x = 5; y = 6;
x = y++ + x++; // x is 11 (5+6)
// y is 7 now
y = ++y + ++x;// 8 + 12
// x = 12, y = 20

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

warning: operation on ‘x’ may be undefined
warning: operation on ‘y’ may be undefined

Why do they ask such questions.

Comment hidden because of low score. Click to expand.
0

I agree that it's very dumb of companies to ask stuff like this. No sane person programs using these sorts of constructs anyway, so if you don't know this kind of stuff, to me that would say good things about you.

Comment hidden because of low score. Click to expand.
0

Its not a warning. Its compile time error in latest version compilers(C-99 onwards).

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

I was asked a similar question during a phone interview.

According to the C standard, you are not supposed to modify a value more than one time between sequence points:

"Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be accessed only to determine the value to be stored."

Each of the assignment statements above falls within a single set of sequence point boundaries. (There is a sequence point at the beginning of the assignment statement and one at the end of the assignment statement, and none in between.) So, according to the standard, this is not a legal C or C++ program.

At least with gcc v4.6.1, the following code generates two different numbers depending on whether the optimizer is enabled:

``````int x, zero;
zero = 0;
x = 5;
printf("(zero + ++x) * (zero + --x):  %d\n", (zero + ++x) * (zero + --x));``````

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

13,21

Comment hidden because of low score. Click to expand.
0

The output of first program is undefined. There is no sequence defined in the statement:
x = y++ + x++;
y = ++y + ++x;

In the older version compilers, the output is 13.......21, but the newer version compilers(c-99 onwards) define the behavior as undefined.You will get the error.
See here: ideone.com/mEqiP

If the value of the same variable is changed more than once, then it is called as UB(undefined behavior).
For more details, search sequence point on wiki.

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.

### 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.