# Subex Papers: Sample Questions 13 - 15 of 19

Examrace Placement Series prepares you for the toughest placement exams to top companies.

## Question number: 13

### Write in Short

What will be the value of dif in the follwing code?

1. `int a[5]={1,2,3,4,5};`
2. `int*p=a+1;`
3. `int*q=a+5;`
4. `int dif=q-p;`

### Explanation

• Here, a is an array of 5 integers, where, a [0] = 1, a [1] = 2, a [2] = 3, a [3] = 4, a [4] = 5
• p and q are the integer pointers. One more integer variable dif is defined as difference of q and p. Here, q – p is evaluated as sizeof (q – p). q is initialized with a + 5 and p is initialized with a + 1. So, difference between both the integer pointers is four. So, 4 will get stored in dif.

## Question number: 14

### Write in Short

What will be the value of y in the following code?

1. `main()`
2. `{`
3. `    int x = 0,y = 1;`
4. `    if (x = y)`
5. `    y = 7;`
6. `    else`
7. `    y = 2;`
8. `}`

### Explanation

• Here, in main () function two integer variables x and y are initialized by 0 and 1 respectively. In if statement assignment operator is placed between x and y. So, no condition will be checked.
• Here it simply assigns the value of y into x and thus x and y posseses same value. As if condition is ssatisfied (i. e. Both variable has same value) else part will not get executed and 7 will be stored in variable y.

## Question number: 15

### Write in Short

What will be the output of the following code?

1. `#define max 10`
2. `main()`
3. `{`
4. `    printf("n%d",max++);`
5. `}`

### Explanation

Here max is preprocessor macro symbol which process first before the actual compilation. First preprocessor replace the symbol to its value in entire the program before the compilation. So in this program max will be replaced by 10 before compilation. Thus program will be converted like this:

1. `main()`
2. `{`
3. `    printf(“n%d”,10++);`
4. `}`

This will generate error because we cannot assign constant value directly. Hence compiler will give error.