char cc = 255;
if(cc == 255)
  printf("cc equal to 255");
  printf("cc not equal 255");
Answer: cc not equal 255

The line cc = 255 will give a warning but not an error in C. After execution of this statement, value of cc will be -1. Char variable takes 7 lower bits as magnitude and the most significant bit as signature. In this case, all bits including the signature bit is 1 which makes it a negative number. The value of the negative number may be calculated as shown below:

Value of 
cc = Negative signature( two's complement of binary 1111111)
   = Negative( not of binary 1111111 + 1)
   = Negative( 0 + 1)

You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

convert case, string to int, int to string, reverse decimal digits, signed and unsigned compare, palindrome digits, upper and lower 16bit of 32bit unsigned, Exchange variables,

# C Programming Language (Prentice Hall Software)
# Let Us C Paperback - 2006 by Yashavant Kanetkar
# Understanding and Using C Pointers Core techniques for memory management
# Data Structures Using C and C++ Paperback - 1998
# Data Structures In C Paperback - August 11, 2008 by Noel Kalicharan