// Exercise 3e for Lecture 3 // functions with different kinds of parameters class Functions { static void Main() { int[] arr = {0,1,2,3,4,5,6,7,8,9}; int x = 0; int n = 3; int n1 = 5; int n2 = 7; int n3 = 9; System.Console.WriteLine("Testing array operations on this array: " + showArr(arr)); System.Console.WriteLine("Get of {0}-th elemnt = {1}", n, Get(arr,n)); System.Console.WriteLine("Setting the {0}-th elemnt to {1}", n1, x); Set(arr,n1,x); System.Console.WriteLine("Modified array: " + showArr(arr)); System.Console.WriteLine("SetSteping the {0}-th elemnt to {1}", n2, x); SetStepBroken(arr,n2,x); System.Console.WriteLine("Modified array: " + showArr(arr)); System.Console.WriteLine("Index = {0}", n2); System.Console.WriteLine("SetSteping the {0}-th elemnt to {1}", n3, x); SetStep(arr,ref n3,x); System.Console.WriteLine("Modified array: " + showArr(arr)); System.Console.WriteLine("Index = {0}", n3); System.Console.WriteLine("Setting all array elements to 0 (using SetStep)"); Set0(arr); System.Console.WriteLine("Modified array: " + showArr(arr)); } static int Get (int[] arr, int n) { return arr[n]; } static void Set (int[] arr, int n, int x) { arr[n] = x; } // this doesn't behave as expected; why? static void SetStepBroken (int[] arr, int n, int x) { arr[n] = x; n +=1 ; } // this increases the index n in each call static void SetStep (int[] arr, ref int n, int x) { arr[n] = x; n +=1 ; } // more generally, such a loop can be used to implement a foreach loop // this requires the use of higher-order functions, i.e. delegates in C# static void Set0 (int[] arr) { int n = 0; while (n