[an error occurred while processing this directive]

CMSC 201 Quiz 1 --- February 20, 1996

Answers are in bold and red .

Thought for the day: What gets us into trouble is not what we don't know. It's what we know for sure that just ain't so. -- Yogi Berra

1. True/false questions

Circle T or F for TRUE and FALSE respectively for each of the following question. (Five point each.)

2. Which of the following is a legal identifier in C? (five points)

3. Which of the following is a C language keyword? (five points)

4. Printf format codes.

Which of the following format codes could be used to print a floating point value in a printf statement? (Five points)

5. What is the value of the following expression?

(Five points)

7 + 2 / 3 - 4 + 4 / 3

In the problems below, Show the output of the following program fragments. Assume everything compiles correctly and don't wory about the exact number of spaces to appear before or after any numeric output.

6. Shorthand expressions (10 points)

  int a, b;
  a = 11;
  b = 27;
  a++;
  a += b;
  b = a - b;
  a -= b;
  printf("a is %d and b is %d\n", a, b);
a is 27 and b is 12

7. Plus-plus (10 points)

  int i, j, k;
  i = j = 0;
  k = 3;
  while ( (i+j) < k) {
    i++;  j++;  k++;
    printf("End of pass %d: j=%d and k=%d\n",i,j,k);
  }
End of pass 1: j=1 and k=4
End of pass 2: j=2 and k=5
End of pass 3: j=1 and k=6

8. Data type conversion (10 points)

  #define pi 3.1416
  int a;
  double b;
  float c;
  b = a = pi*2.0;
  c = (int) pi + a
  printf("a is %d b is %f c is %f\n,a,b,c);
a is 6 b is 6.000000 c is 9.000000

9. Extra credit (1 point)

  int i;main(){for(;i["]


hello, world!
[an error occurred while processing this directive]
Tuesday, 20-Feb-1996 21:30:57 EST