Array is a bunch of similar data that is stored into the variable with the same name, by giving the index in the variable to distinguish from each other.
ARRAY VARIABLES
nama_variabel [index]
provision arrray variable name the same as regular variable names.
index indicates the number of variables.
ARRAY VARIABLE DECLARATION
BU,: type nama_variabel [index];
Example: float bil [10];
array variable declaration with a name that will accommodate 10 bil of data type float. 10 shows the variable bil Index consists of 10 elements, where each element will contain a data.
Array index starts from zero (0), while the number usually starts from a single element (1). Number elements can be made equal to the index numbers to facilitate the manufacture of a program that is by giving the index one more than the amount of data needed, thus becomes:
Float bil [11th]
Initialization DIMENSIONAL ARRAY 1
Initialization can be done in conjunction with or separate declarations. Initialization of an array is to put the array elements between curly braces {}, between elements that are separated from one another comma.
int bil [two] = {4,1,8}
bil Comments [0] = 4
bil [1] = 1
car [two] = 8
AUTOMATIC ARRAY is the array initialization is done in a particular function. Only ANSI-standard C compiler C can initialize automatic arrays.
How to initialize an array of compilers that do not follow the ANSI standard C:
1. Initialized outside the function as a variable GLOBAL / EXTERNAL ARRAY.
int bil [2] = {0,0,0};
main ()
2. Function as a variable is initialized didlm LOCAL / ARRAY STATIC.
main ()
{
static int bil [2] = {0,0,0};
… … …
In automatic array is not initialized, the array would have a value that does not irregular. When global & static array is not initialized then all array elements are automatically given a value of zero (0).
DEFINING THE NUMBER OF ELEMENTS IN ARRAY VARIABLES
The size of the index variable can be determined using
# define preprocessor directive
# Define N 40
main ()
{
int number [N], salary [N], goal [N], status [N], Juman [N];
When Besari index will be changed to 50, simply replaced by
Define N 50 #
2 DIMENSION ARRAY
nama_variabel [indeks1] [indeks2]
indeks1: number / line number
indeks2: number / column number
Number of elements owned by 2-D array can be determined by multiplying indeks1 * indeks2
eg: array A [2] [3] will have a 2 * 3 = 6 elements.
STRING and ARRAY
1. In there is a character string null () at the end of the string
2. Strings are definitely an array, the array is not necessarily a string



Leave a comment