
1) What are three design issues for all datatypes?
Design issues for all datatypes would be to determine,
● The syntax to reference variables
● Operations over specific variables
● The implementation of types in memory
2) (2pts) name three primitive datatypes in C/C++:
Three primitive data types in C/C++ are:
● int
● float
● char
3)(3pts) What are three design issues for string types?
● Choosing how to represent strings internally, such as using an array of characters or to have
it as a primitive type.
● Deciding on the length of the strings whether static or dynamic.
● Determining how strings will be manipulated, including the operations like concatenation,
substring extraction, searching,, etc., as well as how to handle immutable or mutable
strings.
4)(4pts) What is a runtime descriptor – show a runtime descriptor for a dynamic string.
A runtime descriptor includes information about the string's length, capacity, and a reference to
the actual character data. It is used to keep track of the string's characteristics during runtime.
Runtime descriptor for a
Dynamic string
struct DynamicString {
char* data;
size_t length;
size_t capacity;
};
5)(4pts) Give an example of an enumerated type and a subrange type. Which languages allow
these (it can be a different language for each one).
Enumerated Type: Allowed in C/C++, Java, C#
Subrange Type: Allowed in Ada, Pascal
Example:
Enum
enum days {mon, tue, wed, thu, fri, sat, sun}; //C++
Subrange
type Days is (mon, tue, wed, thu, fri, sat, sun);
subtype Weekdays is Days range mon..fri;
subtype Index is Integer range 1..100; //Ada