Complete the code to remove the last element from the array by reducing its size.
int[] arr = {1, 2, 3, 4, 5};
int size = arr.Length;
size = size [1] 1;To delete the last element, we reduce the size by 1 using subtraction.
Complete the code to print the array elements after deleting the last element.
for (int i = 0; i < [1]; i++) { Console.Write(arr[i] + " "); } Console.WriteLine();
We use the updated size variable to print only the elements before the deleted one.
Fix the error in the code that tries to delete the last element by setting it to zero.
int[] arr = {1, 2, 3, 4, 5};
int size = arr.Length;
arr[size [1] 1] = 0;
size = size - 1;To access the last element, subtract 1 from size because array indices start at 0.
Fill both blanks to correctly delete the last element and print the updated array.
int[] arr = {10, 20, 30, 40};
int size = arr.Length;
arr[size [1] 1] = 0;
size = size [2] 1;
for (int i = 0; i < size; i++) {
Console.Write(arr[i] + " ");
}Both blanks use '-' to access the last element and reduce the size by one.
Fill all three blanks to delete the last element, update size, and print the array elements.
int[] arr = {5, 15, 25, 35, 45};
int size = arr.Length;
arr[size [1] 1] = 0;
size = size [2] 1;
for (int [3] = 0; i < size; i++) {
Console.Write(arr[i] + " ");
}Use '-' to access last element and reduce size, and 'i' as the loop variable.
