#include <stdio.h>
int main() {
int array_1[5]; // declaration
array_1[0] = 100;
array_1[1] = 200;
printf("The value of the position 0 in array_1 is %d\n", array_1[0]);
printf("The value of the position 1 in array_1 is %d\n", array_1[1]);
int array_2[] = { 25, 50, 75, 100 }; // initialization
printf("The value of the position 0 in array_2 is %d\n", array_2[0]);
printf("The value of the position 3 in array_2 is %d\n", array_2[3]);
return 0;
}
5. Arrays
•An array is a collection of the data with the same type and stored at
contiguous memory locations
−We use square brackets [] to create arrays
−We use an index number to access the array elements
−The size of an array is fixed once it is declared
Systems Architecture - 2. Basics of C programming 35
The value of the position 0 in array_1 is 100
The value of the position 1 in array_1 is 200
The value of the position 0 in array_2 is 25
The value of the position 3 in array_2 is 100