Predict the output of following program. Assume that the numbers are stored in 2’s complement form.
(B) not same
Explanation: -1 and ~0 essentially have same bit pattern, hence x and y must be same. In the comparison, y is promoted to unsigned and compared against x (See this for promotion rules). The result is “same”. However, when interpreted as signed and unsigned their numerical values will differ. x is MAXUNIT and y is -1. Since we have %u for y also, the output will be MAXUNIT and MAXUNIT.
Quiz of this Question
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference between fundamental data types and derived data types
- C | Data Types | Question 2
- C | Data Types | Question 3
- C | Data Types | Question 5
- C | Data Types | Question 6
- C | Data Types | Question 7
- C | Data Types | Question 8
- C | Data Types | Question 9
- Java | Data Types | Question 1
- Java | Data Types | Question 2
- Java | Data Types | Question 3
- C | Data Types | Question 4
- How to print range of basic data types without any library function and constant in C?
- What are the data types for which it is not possible to create an array?
- Data Types in C
- Interesting facts about data-types and modifiers in C/C++
- What happen when we exceed valid range of built-in data types in C++?
- Linking Files having same variables with different data types in C
- Uninitialized primitive data types in C/C++
- Numeric and Date-time data types in SQL Server