INTRODUCTION TO ARRAY IN C LANGUAGE

INTRODUCTION TO ARRAY IN C LANGUAGE

In this article we’ll study about. INTRODUCTION TO ARRAY IN C LANGUAGE. The C language provides a capability .That enables a set of similar data types. Called Array. This article describes how arrays can created. And manipulated in C. Pointers and arrays are so closely related. That discussing arrays without discussing pointers would make decision incomplete. In fact , all arrays make use of pointers internally. So continuing our topic INTRODUCTION TO ARRAY IN C LANGUAGE.

WHAT ARE ARRAY IN C LANGUAGE:

For understanding arrays properly , lets consider the following program :

#include <stdio.h>
int main() {
int x;
x=5;
x=10;
printf("x= %d\n" , x);
return 0;
}

No, doubt this program will print value of x. As 10. Why so? . Because when a value 10 is assigned to x. The earlier value of x =5 is lost. Thus, ordinary variables are capable of holding one value at a time. However, there are situations .In which we would want to store more than one value. At time in a single variable.

for example:

suppose we wish to arrange the percentage marks . Obtained by 100 students. In ascending order. In such a case, we have two options. To store these marks in memory.

  1. Construct 100 variables to store percentage marks obtained by 100 different students. That means each variable . Containing one student’s marks.
  2. Construct one variable. ( called array or subscripted variable). Capable of storing or holding all the hundred values

Obviously, the second alternative is better. A simple reason for this is. It would be much easier to handle one variable. Than handling 100 different variables. Moreover, there are certain logics. That cannot be deal with. Without the use of array. Now a formal definition of array. An array is collective name given to a group of ‘similar quantities’ . These similar quantities could be. Percentage marks of 100 students. Further What is important is that. Qualities must be ‘similar’. Also Each member in the group is refer to by its position in the group. For example salaries of 300 employees, or age of 50 employees.

For control instructions in c