retagged by
794 views
5 votes
5 votes

Which of the following expressions will evaluate to true?
INT_MIN is the minimum signed integer in the system which is using 2's complement representation for signed integers and variables are defined as follows:

int x = 5, i = -7;
  1. ((x >> 2) << 2) <= x
  2. ~ 1&& 1
  3. INT_MIN == -INT_MIN
  4. -10 < i <-1
retagged by

1 Answer

10 votes
10 votes

int x = 5, i = – 7;

  1. ((x>>2)<<2)<=x
    5 in 4-bit system is 0101
    (0101 >>2) <<2   
    ( 0001 ) << 2
    0100  which is 4
    4 <= 5 is True
     
  2. ~1 && 1
    1 : 0001         ~1: 1110       Both are non-zero
    So    ~1 && 1  is True 
  1. INT_MIN is the minimum signed number in the system. 
    So in a 4 bit system,  INT_MIN = 1000
    Now,  – INT_MIN = 2’s Complement of INT_MIN = 1000
    Hence,   INT_MIN == – INT_MIN  is True  
  1.  −10 < i < −1
    Relational operators ( <, <=, >, >= ) are Left to Right associative 
    So,  (( −10 < – 7 ) < −1 )  
           ( 1 < – 1 )  is False
Answer:

Related questions

6 votes
6 votes
4 answers
1
GO Classes asked Mar 26, 2022
724 views
int find(int n) { int i, j, k, a = 1; for (i = 1; i <= n; i++) for (j = 1; j <= i; j++) for (k = 1; k <= j; k++) a = a + 1; return a; }What will be the value of find$(10)...
5 votes
5 votes
3 answers
3
9 votes
9 votes
2 answers
4