Programming 1 - L6 - Arrays
Programming 1 - L6 - Arrays
Programming 1 - L6 - Arrays
Name of each space in the array Each section of the array is called
An ELEMENT
Student Student Student Student Student Student Student Student Student Student
Num[0] Num[1] Num[2] Num[3] Num[4] Num[5] Num[6] Num[7] Num[8] Num[9]
13 201 55 6 17 89 25 67 351 29
// Outputs 25
Change an Array Element
To change the value of a specific element, refer to the index
number:
printf("%d", myNumbers[0]);
// Add elements
myNumbers[0] = 25;
myNumbers[1] = 50;
myNumbers[2] = 75;
myNumbers[3] = 100;
Loop Through an Array
• You can loop through the array elements with the for loop.
• The following example outputs all elements in
the myNumbers array: