Chapter 1: Data Representation
1. Define the following:
- Built-in data type:
- User-defined data type:
2. Why might a programmer need to use a user-defined data type?
3. Identify and describe two non-composite data types with an example each.
4. Given the declaration TYPE Week: {sun, mon, tue, wed, thu, fri, sat}, write:
- A variable declaration using this type.
- A valid assignment.
5. Describe the purpose and usage of a pointer in programming. Include an example showing:
- Pointer declaration
- Address assignment
- Dereferencing
6. What is a composite data type? Give two examples.
7. Design a record type `Person` with fields: Name, Age, IsStudent.
8. In a class definition, what's the difference between fields and functions?
9. Describe three operations that can be performed on a set data type.
10. Define a set `EvenNumbers` using the correct syntax.
11. Differentiate between serial, sequential, and direct-access files.
12. For each file type (serial, sequential, direct), give:
- A real-world example
- Access method used
- Advantages and limitations
13. Explain the concept of a hashing function and overflow handling.
14. Convert 3.5 to floating point with 8-bit mantissa and 8-bit exponent.
15. Convert -2.5 to floating point with 12-bit mantissa and 4-bit exponent.
16. Why is mantissa normalization important?
17. What happens when the number of bits for the mantissa is too small?
18. How are range and precision affected by mantissa and exponent size?
19. Given mantissa = 011100000, exponent = 00000010, what number is represented?
20. List two reasons normalized mantissas are preferred.