Digital Music Programming
Final Exam (Fujinaga, December 1996)
(5 points per question)
1. If
short tic[3][3] = { {6, 5}, {4}, {3, 2, 1}};
what is?
a. tic[1][0]
b. tic[2][1]
c. **tic + 1
d. **(tic + 1)
e. *(*(tic + 2) + 1)
2. What are the results of the following expressions?
a. 0 && 1 || -3 && 2
b. ((1 < 0 && 1 > 0 )+ 2) & 3
c. 2 + 2 == 2 + 2
d. (3 && 3) ? 3 + 3 && 3 - 3: !(3 - 3) || 3
e. (4 == 4) - 4 + 4 | 4
3. What does the function below return?
int func(int *a, int y)
{
int z = a[0], q = a[0], *p = &a[y];
while (1)
{
while (*--p > q)
;
if (p == &a[0])
break;
a[0] = q = *p;
}
a[0] = z;
return(q);
}
Digital Music Programming (cont.)
4. Explain each of the following:
a. float (*x)[5];
b. int *(*mat[3])[2];
c. struct tab *(*c[4])();
d. int (**pic(int *z))[];
e. long *(*(tix(char *ptr)))();
5. Write a function that takes a midi number and returns a string in pitch-octave names, e.g. af3, cs2, e5.
6. Create an appropriate declaration for each of the following variables:
a. min is an array of 24 struct tabs
b. stop is a pointer to an array of 10 shorts
c. name is an array of 8 pointers to struct people
d. form is an array of 5 pointers to functions returning int
e. hard is a pointer to function returning a pointer to short