Published online by Cambridge University Press: 17 July 2025
The number of variables used so far in a program is very limited. But in real life, plenty of elements are required to be dealt with. Like, we have already written programs to find out maximum between two, three or four variables, but if our task is to find the highest marks in a class of 60 students or more, then it will become a tedious job for us. Which means 60 variables are to be declared to store marks of 60 students, so 60 scanf statements have to be used to take input the marks of each student and finally 60 if statements to find the maximum of these marks and so on. Not only that, if another class contain less or more than 60 students, we could not use this program for that class. We have to rewrite the program according to that new class. Thus this approach of processing a large set of data is too cumbersome and surely not flexible enough. The C language (rather all modern high level languages) provides a more convenient way of processing such collections. The solution is Array or Subscripted variables.
WHAT IS AN ARRAY?
An array is a collection of homogeneous (i.e., same data type) data elements described by a single name and placed in contiguous memory locations. Each individual element of an array is referenced by a subscripted variable, formed by affixing to the array name a subscript or index enclosed in brackets.
Thus by declaring an array we can store a set of values, say 60 of type int in a single variable without declaring 60 different variables of different names. All these values will be stored under a unique identifier (array name).
To save this book to your Kindle, first ensure no-reply@cambridge-org.demo.remotlog.com is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.
Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.
Find out more about the Kindle Personal Document Service.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.