CS1411 - 160 - Programming Principles I, Spring 2005

Lab assignment 5

Motivation

This weeks you will practice arrays

Mandatory work

Your TA will check that you have done the following things (you may leave once their done) :

Array initialization

  • Declare an array a that has 10 spaces.
  • Initialize this array with the = {} method to contain the values 1,2,3,4,5,6,7,8,9,10
  • Print the array on screen using a for loop

Array initialisazion with a for loop

  • Declare an array b that has 20 spaces.
  • Using a for loop, fill this array with the values: 0,2,4,6,8,... (double of the index)
  • Use a for loop to print the array

Email it!

Even if you don't finish the part above, you need to do this step. Please ask you TA if you don't know how! If you are not able to email your program during the test you will get a 0!!!

Email the .cpp file to Yaoqin Jing. Include you FULL NAME!

Please note: You still have to be present in the Lab and do you work there. It is not sufficient to just email the program!

Optional work

Some other things that you might try:

  • Fill the array using a loop with the values 0,1,4,9,16,... (squares)
  • Print the array backwards
  • set a[0] = 0, and a[i] = a[i]+i for i>0. What is the result?

How?

Please check the labs page on how to get started. There are instructions for visual studio (use version 6) and XCode

Please give the Macs a try. If you simply cannot work with them, go to PE 119, but let your TA know.

Sample programs

have moved to the examples page

Help!

For help: ask your TA! He is here to help you!

If the instructions are unclear or you have any other questions, please email me