Arrays
CHAPTER OUTLINE
7.1
Introduction
7.2 Array Initialization
7.3
Definition of Array
7.4 Characteristic of Array
7.5 One-Dimensional Array
7.6
Predefined Streams
7.7 Two-Dimensional Array
7.8
Three or Multi Dimensional Arrays
7.9
The sscanf () and sprintf () Functions
Exercises
7.1 INTRODUCTION
Consider the following example.
main()
{
int a=2;
a=4;
printf ("%d",a);
}
OUTPUT: 4
In the above example the value of 'a' printed is 4. 2 is assigned to 'a' before assigning 4 to it.
When we assign 4 to 'a' then the value stored in 'a' is replaced with the new value. Hence, ordinary
variables are capable of storing one value at a time. This fact is same for all the data types. But in
application the variables must be assigned to more than one value. This can be obtained with the
help of arrays. Array variables are able to store more than one values at a time.
Declaration of an array is done as follows
in t a [5];
It tells to the compiler that 'a' is an integer type of arijay and can store 5 integers. The compiler
reserves 2 bytes of memory for each integer array element.

Get Programming and Data Structures now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.