Computer Science 433
Programming Languages

Fall 2014, The College of Saint Rose

Program/Problem Set 7: Names and Data Types
Due: 11:59 PM, Wednesday, October 29, 2014

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

Langauges on mogul

This assignment will ask you to write programs in four languages: C, C++, C#, and Java. Please make sure all programs run on mogul. In case you never knew or have forgotten, here is how to compile and run a program in each of these languages (using examples from the late penalty calculators in the shared area).

Questions and Programs

All programs required are to be treated as "Practice Programs" in terms of collaboration and grading. You are welcome to discuss them with your classmates, and I will grade only on correctness, not documentation, style, etc. Of course, you should still make sure your name is in every file you submit! Unless otherwise specified, all programs should be included in your submission and you should make sure they run on mogul.

Question 1: Compute the address of the [5][2] element in a 10 ×10 2-dimensional array of integers (4 bytes each) called IntArray where the initial address for the array starts at 00004400 for C++ and Fortran. Show your work. (4 points, 2 each)

Question 2: Do Sebesta Programming Exercise 5, p. 241. Note that in order to make some of your programs compile, you might need an instance or global variable also named x outside of your function or method's scope, and you'll want to sprinkle in some appropriate printouts so you can better see what's happening. And don't forget to explain what you found in addition to submitting your three programs. (8 points)

Question 3: Do Sebesta Programming Exercise 6, p. 241. To clarify, the programs should demonstrate whether a variable declared in the initialization part of the for loop declaration (not the body of the loop) is visible outside the loop. Be sure to state the scoping rules you discovered for each of these languages. (5 points)

Question 4: Do Sebesta Programming Exercise 7, p. 241. You could time your code by instrumenting it with timers (see, for example, C's gettimeofday function), or by timing the execution of your entire program with the Unix time command. The time command can be added before any Unix command line and an extra line of output will appear after your program's output that includes useful information including the wall-clock and CPU time taken to run your program. And don't forget the last sentence of the problem: "Explain the results." (8 points)

Submission

Before 11:59 PM, Wednesday, October 29, 2014, submit your work for grading. Create and submit a single archive file (a .7z or .zip file containing all required files) using Submission Box under assignment "PS7".

Grading

This assignment will be graded out of 25 points.

Feature

Value Score
Question 1: computing addresses 4
Question 2: Programming Exercise 5 programs 6
Question 2: Programming Exercise 5 explanation 2
Question 3: Programming Exercise 6 programs 3
Question 3: Programming Exercise 6 results 2
Question 4: Programming Exercise 7 program 6
Question 4: Programming Exercise 7 explanation 2
Total 25