Study Circle Project
Computer Organization I, Autumn 2005, Study Circle Project PR 1
Report contents
are defined in the Study Circle description and the report deadline 27.11.2005 at 23:55.
Design and implement one (1)
practice problem
.
The topic for the practice problem is selected in the following manner:
Take the day part of each participants birt date (E.g., number 5, if you were born 5.3.1988)
Add up all day parts. (E.g., 5+13+8+25 = 51)
Divide by four, take remainder and add one. (E.g., . "51 mod 4" +1 = 3+1 = 4)
use the result to select the lecture numebr for your topic. (E.g., Lecture 4)
Design and implement a ttk-91 program that includes the following parts:
function Alusta(T, n, x, y, z), that initializes a 2D array T[n,n] so, that T[i,j] = i*x + j* y + z;
T is call-by-reference parameter, the others are call-by-value parameters
must have 1 < n ≤ 20, -20 ≤ x ≤ +21, -100 ≤ y ≤ +100
, -1000 ≤ z ≤ +1000
returns value 0, if all OK, and value ≠ 0, if some problem or error.
(You can code the problem type into the return value, of you so wish.)
function Tulosta(T, n, i, j), that prints the value of element T[i, j] in 2D-array T[n,n]
T is call-by-reference parameter, the others are call-by-value parameters
must have 1 ≤ n ≤ 20, 0 ≤ i < n, 0 ≤ j < n
returns value 0, if all OK, and value ≠ 0, if some problem or error.
function Summa (T, U, V, n), that computes the element-wise sum T = U+V, so that T[i,j] = U[i,j] + V[i,j]
T, U, V are call-by-reference parameter, the others are call-by-value parameters
must have 1 ≤ n ≤ 20
returns value 0, if all OK, and value ≠ 0, if some problem or error.
main program, where
define 2D arrays A[2,2], B[2,2] and C[2,2] as well as E[5,5], F[5,5] and G[5,5]
initializes with function Alusta() the array A so that A[i,j] = i + 2j + 1
initializes with function Alusta() the array B so that B[i,j] = 2i + 40j - 23
computes with function Summa() the array C so that C = A+B
prints out values A[1,0], B[1,0] ja C[1,0]
initializes with function Alusta() the array E so that E[i,j] = i + j
initializes with function Alusta() the array F so that F[i,j] = i - j
computes with function Summa() the array G so that G=E+F
reads index values for i and j from the user
checks, that 0 ≤ i < 5 and 0 ≤ j < 5
prints with function Tulosta() the values E[i,j], F[i,j], and G[i,j]
repeats the previous three steps until pair (0,0) is given as input
Follow the recommended subroutine (function) call mechanisms given in the lectures.
Teemu Kerola