CS140 -- Midterm Exam: Q1 - Q3

October 8, 1998


Multiple Choice

Unless indicated, circle the one answer that answers the question. Please do this on the answer sheet given.

The following code is for questions 1, 2 and 3:
a(int i, int j)
{
  i = j + i;
  printf("%d 0x%x\n", i, j);
  j -= 4;
}

main()
{
  int i, j;

  i = 2;
  j = 10;
 
  printf("%d %d\n", i, j);
  a(i, j);
  printf("%d %d\n", i, j);
} 
The following choices will be for questions 1 through 3:

a. 2 6
b. 2 0x6
c. 2 10
d. 2 0xa
e. 2 0x10
f. 12 6
g. 12 0x6
h. 12 10
i. 12 0xa
j. 12 0x10


Question 1: What is the first line of output when the above code is compiled and executed?

Question 2: What is the second line of output when the above code is compiled and executed?

Question 3: What is the third line of output when the above code is compiled and executed?