CS 321 Spring 2013  >  Assignment 2

CS 321 Spring 2013
Assignment 2

Assignment 2 is due at 5 p.m. Thursday, February 14. It is worth 25 points.

Procedures

E-mail answers to the exercises below to ggchappell@alaska.edu, using the subject “SA2”.

Exercises (25 pts total)

Exercise A — Delegated Computation

Purpose

In this exercise, you will write a C++ program that performs a number of computations, spawning a separate thread for each.

Instructions

Write a complete C++ program as follows.

Sample Run

Here is a sample run of delegate.cpp. Actual return values may be different.

Delegated Computation

Enter a positive integer (or 0 to end input): 1
Enter a positive integer (or 0 to end input): 2
Enter a positive integer (or 0 to end input): 24
Enter a positive integer (or 0 to end input): 3
Enter a positive integer (or 0 to end input): 4
Enter a positive integer (or 0 to end input): 0

sa2a(3) = 1002
sa2a(4) = 6
sa2a(1) = -5
sa2a(24) = 37
sa2a(2) = 6

Coding Standards

The following are standards for all programming assignments in this class.

The above requirement is absolute; if your code does not compile, then there is no point in turning it in.

In addition, to receive full credit, submitted code should satisfy the following conditions.


CS 321 Spring 2013: Assignment 2 / Updated: 11 Feb 2013 / Glenn G. Chappell / ggchappell@alaska.edu