C - Operators and Expressions
C - Operators and Expressions
61. Which of the following expressions will correctly swap two integers without using a temporary variable ?
- (x ^ = y), (y^=x)
- (x=y), (y = x)
- (x ^ = y), (y ^ = x), x ^ = y)
- x^=(y^x)
62. What is the correct and fully portable way to obtain the most significant byte of an unsigned integer x ?
- x & & 0xFF00
- x >> 24
- x >> (CHAR - BIT * (sizeof(int)-3))
- x >> (CHAR _ BIT * (sizeof (int)-1))
64. For the following statements find the values generated for p and q ?
int p = 0, q = 1;
p = q++;
p = ++q
p = q--;
p = - - q;
The value of p and q are
int p = 0, q = 1;
p = q++;
p = ++q
p = q--;
p = - - q;
The value of p and q are
- 1, 1
- 0, 0
- 3, 2
- 1, 2
65. Which of the following is a better approach to do the operation i = i * 16;?
- multiply i by 16 and keep it
- shift left by 4 bits
- add i 16 times
- none of the above