Ticker

6/recent/ticker-posts

C Language (Introduction To Array)

ARRAY INTRODUCTION IN C
Array is a collection those values which are related with same data type.
Suppose we want to insert marks for class XII students and total 50 students are there.
Every student require marks for five subjects. 
So we need to declare (50 x 5 = 250) variables that need several lines code but by using of array we can do this task by just one variable.
int m[250]






ARRAY EXAMPLE IN C
int a[40]

Explanation: in the above statement “int” is a predefined data type in C language and it is used to create a variable in the C language.
“a” is name of array and [40] is size of the array.


FEATURES OF ARRAY
1. Array is an example of static data type and static memory should be allocate before the run time, therefore it causes of overflow and underflow errors.

2. In array all elements store in one variable by help of unique index number and first value of array always store in zero (0) index number.


3. All the elements of array should be related with their one data type.



HOW TO DECLARE ARRAY IN C LANGUAGE
int m=[5];

Explanation: In the above example, we are declaring an integer array with the help of 'int' data type and as we know, that array stores its value by help of unique index number.
m[0] = 4
m[1] = 7
m[2] = 5
m[3] = 9
m[4] = 8

LEARN DATA TYPES IN C














HOME



Post a Comment

0 Comments