[an error occurred while processing this directive]
Recitation 2 Exercises (19/20 September 2012)
Before each recitation we will post a short set of written exercises. These are intended to help you prepare for recitation. You must complete them to the best of your ability, and bring them to recitation. Your TAs will note whether you have completed them along with your attendance. These exercises will not be graded for correctness, but you must attempt to answer them and bring your answers to recitation. A portion of your grade depends on your attempting these exercises each week and attending recitation.
We will talk about arrays in lecture on Wednesday. If you don't understand the questions, wait until after lecture to work on them.
Question 1 Write a program that declares and initializes an array a of size 1000 and accesses a. Does your program compile? What happens when you run it?
Question 2 What does the following code fragment print? Try and work the solution out by hand, then try it in Dr. Java if you wish.
int  a = new int; for (int i = 0; i < 10; i++) a[i] = 9 - i; for (int i = 0; i < 10; i++) System.out.print(a[i] + " "); System.out.println(); for (int i = 0; i < 10; i++) a[i] = a[a[i]]; for (int i = 0; i < 10; i++) System.out.println(a[i] + " "); System.out.println();