3. Introduction
1. An array is a collection of data items, all
of the same type, accessed using a
common name.
2. A one-dimensional array is like a list
3. A two dimensional array is like a table The
C language places no limits on the number
of dimensions in an array, though specific
implementations may.
4. Need of an Array
1. Faster and can be utilized anywhere.
2. Store data of similar data types together
and can be used anywhere in the code.
3. All the elements of an arrays are stored in
the homogeneous memory location
8. Input Array Elements
1D Array:
int mark[5] = {19, 10, 8, 17, 9};
int mark[] = {19, 10, 8, 17, 9};
scanf("%d", &mark[2]);
So for entering 1000 variables shall we use 1000 scanf()
statement …….
9. Input Array Elements
void main()
{
int values[5],i;
printf("Enter 5 integers: ");
// taking input and storing it in an array
for( i = 0; i < 5; ++i)
{
scanf("%d", &values[i]);
}
printf("Displaying integers: ");
// printing elements of an array
for( i = 0; i < 5; ++i)
{
printf("%dn", values[i]);
}
}