CSCI 1301 – Lab 22

Clément Aubert

April 1, 2019

First Array Maniplation

Write a program that

  1. declares an array myArray of int of size 5,
  2. intitializes myArray with the values 1, 2, 3, 4 and 5,
  3. displays the content of myArray.

Now, let us write incorrect statements. Add the following statements one by one to your program, observe how C# react (that is, try to compile and execute after you added one, then remove it), and answer the following questions.

myArray = { 1, 2 ,3, 4, 5};
Console.WriteLine (myArray[5]);
myArray[5] = 12;
Console.WriteLine(myArray);

Second Array Maniplation

Write a program that

  1. declares an array myArray of int of size 10,
  2. intitializes myArray with the values 1, 2, 3, …, 9 and 10,
  3. displays the content of myArray.
  4. sum the values stored in myArray and display the result.
  5. make the product of the values stored in myArray and display the result.