# Languages-C & C Plus Plus [HCL Placement]: Sample Questions 9 - 10 of 12

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

## Question 9

### Explanation

The given number is 0xFEDB, a hexadecimal number.

First convert the given hex number into decimal number.

Now convert this decimal number into base 8 (octal) number.

Dividing 65243 by 8, quotient will be 8155 and remainder will be 3.

Dividing 8155 by 8, quotient will be 1019 and remainder will be 3.

Dividing 1019 by 8, quotient will be 127 and remainder will be 3.

Dividing 127 by 8, quotient will be 15 and remainder will be 7.

Dividing 15 by 8, quotient will be 1 and remainder will be 7.

Dividing 1 by 8, quotient will be 0 and remainder will be 1.

Now reversing the direction of remainder from bottom to up we can get the number in octal format.

Here, the octal form number of FEDB will be 177333.

## Question 10

### Question

MCQ▾What is the output of the following program?

`main()`

`{`

`int x=20;`

`int y=10;`

`swap(x,y);`

`printf("%d %d",y,x+2);`

`}`

`swap(intx,int y)`

`{`

`Int temp;`

`temp =x;`

`x=y;`

`y=temp;`

`}`

### Choices

Choice (4) | |
---|---|

a. | 20,12 |

b. | 10,20 |

c. | 22,10 |

d. | 10,22 |

### Answer

a.### Explanation

- In the main () function two integer variables, x and y are initialized with 20 and 10 respectively. In the swap function we are passing two arguments, x and y. We want to swap the values stored in X and Y. For it we have first defined one temporary variable, temp. The next three lines is the code for interchanging the values of X and Y.
- temp = x, i.e.. we are storing value of x in temp.
- x = y, i.e.. we are storing value of y in x.
- y = temp, i.e.. we are storing value of temp in y.
- Now, the values of x and y has been interchanged. So, now x is 10 and y is 20.
- We want to print the value of y and x + 2, which will be 20 and 12 respectively.