Arrays manipulation and sorting for development 3

workgodwinlarry 7 views 4 slides Mar 05, 2025
Slide 1
Slide 1 of 4
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4

About This Presentation

Arrays manipulation and sorting for development


Slide Content

Arrays

Content
To assign values to the array:
int[] numbers = new int[] {1, 2, 3, 4, 5};
And to access an element in the array, use the index of that element (keep in mind that
indexing starts at 0):
int[] numbers = new int[] {1, 2, 3, 4, 5};
Console.WriteLine(numbers[0]);
// Output: 1

Practice
Fill in the code to create an integer array called nums that holds numbers from 1 through
5:
???[] ??? = new int[] {???};
int
nums
1, 2, 3, 4, 5
1-5
integers
numbers

Revision
Fill in the code to output the number 7 from the numbers array using its index:
int[] numbers = new int[] {1, 3, 5, 7, 9, 11};
Console.WriteLine(numbers[???]);
// Output: 7
3
7
4
1
Tags