

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Professor: Sussman; Class: ORGNZTN PROGM LANG; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;
Typology: Exams
1 / 3
This page cannot be seen from the preview
Don't miss anything!


CMSC 330 Practice Final Examination
Show all work necessary to justify your answers! There are 7 questions.
(a) value? (b) value-result? (c) reference?
#include <iostream.h> int k = 5;
void f(int i, int j) { if (i < 4) i = i + 1; else i = i - 1; j = j + 2; k = k - 1; }
main() { int j = 3; f(j, k); f(k, j); cout << j << " " << k << '\n'; }
struct S { char c[2]; float f; double d[2]; int i; } A[30,20,10];
For this problem assume that chars take up one byte, ints and oats take up 4 bytes each and doubles take up 8 bytes, and that the elds in a structure must have their natural alignment.
(a) (5 p oints) Show the layout of variables of typ e S, with the o set of the rst eld in the structure b eing 0. (b) (10 p oints) Assuming that array indices always start at 0 and the start address for array A is 1000, what will b e the address of A[20,5,5], if A is stored in: i. row ma jor order? ii. column ma jor order?
(a) What is the representation for the set A = [banana, kiwi], and the set B = [straw- berry, kiwi, plum, grapefruit]? (b) What machine instruction could b e used to p erform the op eration C = A [ B , and what is the representation for C? (c) What op erations must b e p erformed to test whether the element blueberry is in the set C? Show b oth the set op erations and machine instruction(s) required.