801 views
6 votes
6 votes
In $C$ programming, constant integers are considered to be signed integers by default. One way to represent them as an unsigned constant is by appending $U$ as a suffix. For example, $-1$ is signed whereas $-1U$ is unsigned.
Which of the following condition(s) is/are $\text{TRUE}$?
  1. $-1 > -2$
  2. $-1U > -2$
  3. $-1 > 0U$
  4. $-1 > 0$

1 Answer

5 votes
5 votes
Option $A$ is true since $-1$ is greater than $-2$ (both are signed here)
Option $B$ is true since $-1$ unsigned is the largest number in unsigned (all ones in binary), therefore, it is greater than any other integer possible. Although here $-2$ will be treated as the unsigned but final result will be true.
Option $C$ is true since $-1$ will be treated as an unsigned number because of $0U$. And we know that $-1$ as unsigned is the largest integer.
Option $D$ is false. This is signed comparision.
Answer:

Related questions