An array in C programming language is an identifier which is used for storing large set of data with a common name. Note that a variable can store only a single data.
Arrays are of two types:
Arrays are of two types:
1 . One-dimensional arrays
2 . Multidimensional arrays
2 . Multidimensional arrays
One dimensional arrays :
Definition: Arrays are defined like the variables with an exception that each array name must be accompanied by the size (i.e. the max number of data it can store).For a one dimensional array the size is specified in a square bracket immediately after the array`s name as shown below. In this c programming tutorial we use both types of arrays in our c programs.
Datatype array name[size];
So far, weve been declaring simple variables: the declaration int i; declares a single variable, named i, of datatype int. It is also possible to declare an array of several elements.
The declaration int a[100]; declares an array in c language( for which 100 size of memory is kept reserved for it), named a, consisting of hundred elements, each element will be of type int. in Other words , an array simply is a variable that can hold more than one value.
Examples :
int x[100];
float mark[50];
char name[30];
the declaration int x[100] allows process to creates 100 memory cells starting from x[0],x[1],x[2],………,x[99].
int x[100];
float mark[50];
char name[30];
the declaration int x[100] allows process to creates 100 memory cells starting from x[0],x[1],x[2],………,x[99].
One-dimensional arrays initialization in C programming
int weekdays[7]={1,2,3,4,5,6,7};
Multidimensional Arrays in c language:
Miltidimensional arrays contains two portions rows and columns such as
Datatype array name[rows][column];
Datatype array name[rows][column];
Multidimensional arrays initialization:
int c[2][3]={{1,3,0}, {-1,5,9}};
int c[2][3]={{1,3,0}, {-1,5,9}};
0 comments:
Post a Comment