Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Assignment of Programming Languages in Computer Science, Assignments of Programming Languages

Assignment of Programming Languages in Computer Science

Typology: Assignments

2021/2022

Uploaded on 04/12/2024

begin-with-yes-diy
begin-with-yes-diy 🇺🇸

1 document

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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

Partial preview of the text

Download Assignment of Programming Languages in Computer Science and more Assignments Programming Languages in PDF only on Docsity!

  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