What is an Array in C Language ??? with Free Notes

Introduction – Array

Array – Till now we have used scalar variables or non-subscripted variables. This type of variables represents a memory location in which a single value is stored. Many a times a situations may arise in which, there is a need to process a collection of homogeneous or similar type of values. In C, array is one such type of data structure that can store a group of similar type of data elements stored in contiguous memory locations. The array elements are accessed by providing the name if the storage area or array and a subscript representing the position of the element within Array. The illustrate this consider a class of 40 students with their marks in an examination.

We want to find out the following:

  • maximu score
  • minimum score
  • average score
  • number of students who got first division
C Language E-book

In such case we have two options to store the marks in memorr.

  1. Use 40 variables to store their individual marks.
  2. Use one variable which is called as array or subscripted variable to store 40 values. Out of these two options, obviously better option is to use on variable i.e. an array variable. Because it is very easy to handle one variable as compare to 40 variables.

e.g. By using first option we can define 40 variables as

int s1, s2, s3, s4, .....,s40;

Whereas by using second option we can define it as

int s[40];

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top