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)
Show Answer
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))
Show Answer
63.  What is the value of the following expression ?
i = 1;
i << 1 %2
  • 2
  • -2
  • 1
  • 0
Show Answer
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

  • 1, 1
  • 0, 0
  • 3, 2
  • 1, 2
Show Answer
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
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test