# Languages [HCL Placement]: Sample Questions 9 - 10 of 13

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

### Write in Short

Short Answer▾What will be the output of the following?

`main()`

`{`

`inti;`

`char ⚹p;`

`i=0X89;`

`p=(char ⚹)i;`

`p++;`

`printf("%xn",p);`

`}`

### Explanation

- In the main () function one integer variable i is declared and one more character pointer p is declared. Here, variable i is defined with hex value 89. In the next statement we are defining pointer p with value at the address of i. So, now p will contain value 0X89. Then we are incrementing the pointer by one value. So, now value of p is incremented by 1. So, value in the p will be 0x8A. As in hex numbers 0 to 9 numbers and A to F letters are used to represent total 0 to 15 numbers.
- A represents number 10, B represents number 11, C represents number 12, D represents number 13, E represents number 14, F represents number 15. In the printf statement we want to print the value stored in pointer p. % x is the format specifier for hex (base 16) value. So, output of the program will be 0X8A.

## Question 10

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