1.2 KiB
1.2 KiB
- Which of the following aren not legal types in C?
a. short unsigned int
b. short float
c. long double
d. unsigned long
Answer:
b. short float
- If
cis a variable of typechar, which of the following statements is illegal?
char c;
// A:
i += c; // i has type int
// B:
c = 2 * c - 1;
// C:
putchar(c);
// D:
printf(c);
Answer:
D is illegal because printf operates on strings, not chars.
- For each of the following items of data, specify which one of the types
char,short,int, orlongis the smallest one guaranteed to be large enough to store the item.
Answer:
A. Days in a month: char
B. Days in a year: short
C. Minutes in a day: short
D. Seconds in a day: long
- Suppose that
iis a variable of typeint,jis a variable of typefloat, andkis a variable of typeunsigned int. What is the type of the expressioni + (int) j * k?
Answer:
unsigned int
- Use
typedefto create types namedInt8,Int16, andInt32. Define the types so that they represent 8 bit, 16 bit, and 32 bit integers on your machine.
Answer:
typedef char Int8;
typedef short Int16;
typedef long Int32;