Computer Science 340
Programming Languages

Fall 2023, Siena College

Problem Set 6: Datatypes
Due: 11:59 PM, Wednesday, November 8, 2023

This problem set consists of a short programming task and other questions. You may work alone or with a partner on this assignment.

Getting Set Up

In Canvas, you will find a link to follow to set up your GitHub repository, which will be named datatypes-probset-yourgitname, for this problem set. Only one member of the group should follow the link to set up the repository on GitHub, then others should request a link to be granted write access.

All GitHub repositories must be created with all group members having write access and all group member names specified in the README.md file by 11:59 PM, Friday, November 3, 2023. This applies to those who choose to work alone as well!

Questions and Program

The program is to be treated as a "Practice Program" in terms of collaboration and grading. Written responses may be in a PDF file included in your repository or in the repository's README.md file.

Question 1: Given a two's complement, Little Endian architecture, show the contents of memory needed to store the 32 bit integer -17, located starting at address 00CCCC00. (3 points)

Address

Contents
00CCCC00
00CCCC01
00CCCC02
00CCCC03

Question 2: Compute the address of the [5][2] element in a 10 ×6 2-dimensional array of integers (4 bytes each) called IntArray where the initial address for the array starts at 00004400 for C++ and Fortran. Be sure to consider language differences including the index of the first element in an array (0 or 1) and whether the language uses row-major or column-major order for multidimensional arrays. Show your work. (6 points, 3 each)

Question 3: Give the IEEE 754 32-bit representation of the number 16.25. Do not worry about endianness. (3 points)

Sign Bit

          Exponent                                   Mantissa                       
 

Question 4: Give the BCD representation for the number 2615 in binary and in hexadecimal. (4 points)

Question 5: Summarize the essential differences between the mechanisms to handle character strings in C and Java. (4 points)

We saw in the example of Pascal subranges that with the fpc compiler on noreaster, an assignment of a variable to a constant outside of the subrange generates a warning at compile time, but that values outside the range are still allowed.

Question 6: Describe what the language's run-time system would need to do to enforce ranges of computed values at run time. For example, to generate an error from the statement below in the Pascal subranges program. (5 points)

  Minute := Minute * 3;

Question 7: Draw a picture of the memory allocated for a 4 ×4 two-dimensional array for a rectangular allocation (true two-dimensional array) and a jagged allocation (array of arrays) in C. (5 points)

Question 8: Write a short Python program that creates and populates an array, then takes a slice through the array that takes every third element, starting with the second element (i.e., the element at subscript 1). (5 points)

Question 9: Do Sebesta Programming Exercise 7 at the end of Chapter 6, p. 299. (10 points)

Submission

Commit and push!

Grading

This assignment will be graded out of 45 points.

Feature

Value Score
Q1 3
Q2 6
Q3 3
Q4 4
Q5 4
Q6 5
Q7 5
Q8 5
Q9 10
Total 45