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

C & C Plus Plus
Edit

Write in Short

Convert hexadecimal number 0xFEDB to the octal.

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

C & C Plus Plus

Question

MCQ▾

What is the output of the following program?

1. main()
2. {
3.     intx=20;
4.     inty=10;
5.     swap(x,y);
6.     printf("%d %d",y,x+2);
7. }
8. swap(intx,inty)
9. {
10.     Inttemp;
11.     temp =x;
12.     x=y;
13.     y=temp;
14. }

Choice (4)

a.

20,12

b.

10,20

c.

22,10

d.

10,22