l4 - int y = {10, 20, 30, 40 , 50}; for (int i =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS121 Autumn 2009 Lecture #4 exercises The purpose of these exercises is to allow you to test your understanding of the material covered in today’s lecture. You are welcome to turn in your answers at the next lecture to get feedback from us, but you are not required to do so. These exercises are intended to take less than an hour and a half, assuming you have done the reading. Exercise 1: What element does the array z contains after the following code is executed: int[] z = new int[8]; z[1] = 4; z[4] = 99; z[7] = 2; int x = z[1]; z[x] = 44; z[z[7]] = 11; Exercise 2: What is the output of the following code fragment:
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int y = {10, 20, 30, 40 , 50}; for (int i = y.length-1; i>=0; i--) { System.out.printf("%s ", y[i]); } System.out.printf("\n"); Exercise 3: Given an array of doubles, called temps , that represents the high temperature for a sequence of days, write code that computes the number of days that had above average temperatures. Exercise 4: Given an array of ints, called x , write code that rotates the elements of the array right by 1 with the last element where the last element rotates into the rst position in the array. For example:...
View Full Document

Ask a homework question - tutors are online