Department of Electrical Engineering and Computer Science
6.087: Practical Programming in C
IAP 2010
Problem Set 2
Types, operators, expressions
Out: Tuesday, January 12, 2010. Due: Wednesday, January 13, 2010.
Problem 2.1
Determine the size,minimum and maximum value following data types. Please specify if your
machine is 32 bit or 64 bits in the answer.
• char
• unsigned char
• short
• int
• unsigned int
• unsigned long
• float
Hint: Use sizeof() operator,limits.h and float.h header files
Problem 2.2
Write logical expressions that tests whether a given character variable c is
• lower case letter
• upper case letter
• digit
• white space (includes space,tab,new line)
Problem 2.3
Consider int val=0xCAFE; Write expressions using bitwise operators that do the following:
• test if atleast three of last four bits (LSB) are on
• reverse the byte order (i.e., produce val=0xFECA)
• rotate fourbits (i.e., produce val=0xECAF)
1