CS 2401 Quiz #1

Date: Friday, June 15, 2012.

1. What will be the printed as a result of the following code:

  double[] s = {3.14, 2.15, 1.92, 0.65};
  double[] t = new double[4];
  double[] c;
  c = t;
  c[3]++;
  System.out.println(c[3]);
  System.out.println(s[2]);







2. Write down a piece of code to print out 5 random elements of an array, each on a separate line, followed by the product of these numbers on a separate line.














3. Write down a piece of code for computing the double average value of the elements of an array of integers. Trace your code on an example array consisting of the numbers 2, 4, and 1.