Laboratory Exercises For Computer Science 295

Lab 1: Sequential Elements of the SR Programming Language

Lab 1: Sequential Elements of the SR Programming Language

Goals: This lab provides experience with the sequential elements of the SR programming language.

Resources:

Steps for this Lab:
  1. Copy the darts program ~walker/parallel/sr/examples/darts.sr to your account. Compile it with the statement
    
         sr -o darts darts.sr
    
    Run it by typing darts.

  2. Edit darts.sr to introduce a variety of typographical errors. After creating each error, try recompiling and note how the compiler responds.
  3. Write an SR program which uses the random number generator to simulate the rolling of a die 10 times. The program should print the results of each roll.
  4. Modify the previous program to record the number of 2's that are obtained when a die is rolled 1000 times. (The program should not print the results of each roll -- only the total number of 2's out of the 1000 rolls.)
  5. Modify the previous program to record the number of times that one roll of a die gives the same result as the previous roll over 1000 rolls of the die. For example, in the sequence 6, 5, 5, 2, 2, 2, the program should print the count 3 (the double 5's gives one duplicate and the sequence 2, 2, 2 contains the duplicate 2, 2 twice).
    Compare the results you obtained on this part and on the previous part. Explain any similarities or differences in the results obtained.
  6. Write a program for Section 2.3.1 in Hartley's text.
    In this assignment, your program must have at least one procedure and must show the use of both value and reference parameters.


Format for Submitting Lab Work All programs for this course must start with the following header:


    # Your name
    # Assignment or Lab Title
    # Short description
Once a program is in its final form, it should be submitted using the following steps:


Work to be turned in:


This document is available on the World Wide Web as

     http://www.math.grin.edu/~walker/courses/295/lab1.html

created January 13, 1997
last revised January 17, 1997