---
title: CSCI 1301 -- Lab 22
author: Clément Aubert
lang: en
fontsize: 10pt
documentclass: scrartcl
numbersections: true
links-as-notes: true
papersize: letter
geometry: margin=1in
keywords:
- Computer Science
- Problem solving methods
- Syllabus
- Augusta University
- Bachelor of Science
---


# First Array Maniplation

Write a program that

#. declares an array `myArray` of `int` of size $5$,
#. intitializes `myArray` with the values $1$, $2$, $3$, $4$ and $5$,
#. 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.

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

- One of this statement is not "incorrect" in the sense that it won't prevent your program from executing, but it is not doing what you could have expected: which one?
- Can you read and understand the errors messages you obtained for the others?

# Second Array Maniplation

Write a program that

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

