Professional Documents
Culture Documents
C/C++ Programming I
1. The data type of the literal 252767 is: 4. Predict the values of 5 / -2 and 5 / -2.0
(Notes 2.1 & 2.2) (Note 2.8)
A. implementation dependent A. two possibilities: -2 and -2.5 or -3 and
B. long -2.5
C. int B. A general prediction cannot be made
D. not defined in standard C for all implementations
E. none of the above C. None – a compiler or run time error
occurs
2. The data types of: D. -2, -2.500000
a) unsuffixed floating literals and E. two possibilities: -2 and -2.5 or -1 and
b) unsuffixed integer literals, are: -2.5
(Notes 2.4 and 2.2A)
A. implementation dependent in both 5. If char is 8 bits and int is 16, predict the
cases. values of -7 % 3 and sizeof(-5 % 3)
B. determined by the value of the literals in (Notes 2.8 & 2.12)
both cases. A. two possibilities: -1 and 2 or 2 and 2
C. a) double B. A general prediction cannot be made
b) determined by the number of digits for all implementations.
D. a) double C. -1 and 2 or -1 and 4 depending upon
b) determined by the value and base of the data type of sizeof
the literal D. two possibilities: -1 and 2 or 1 and 2
E. none of the above E. three possibilities: -1 and 2 or 2 and 2
or -2.3 and 2
3. A mathematical operation where all
operands are type char is: 6. Which of the following guarantees the
(Note 2.10) correct answer on any machine?
A. illegal - type of char is only used for (Notes 2.10 & 2.11)
character operations. A. long value = 300 * 400 * 10L;
B. evaluated using type signed char B. long value = 300 * 400L * 10;
arithmetic. C. float value = 300 * 400 * 10;
C. evaluated using type char arithmetic. D. double value = (double)(300 * 400 * 10L);
D. evaluated using type int or unsigned int E. none of the above because the value
arithmetic. of each is implementation dependent
E. not as accurate as an operation with all
type long operands.