Skip to main content Accessibility help
×
Hostname: page-component-6bb9c88b65-wr9vw Total loading time: 0 Render date: 2025-07-27T03:51:06.049Z Has data issue: false hasContentIssue false

11 - Array

Published online by Cambridge University Press:  17 July 2025

Subrata Saha
Affiliation:
Techno India Hooghly, West Bengal
Subhodip Mukherjee
Affiliation:
Techno India College of Technology, West Bengal
Get access

Summary

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).

Information

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2016

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Book purchase

Temporarily unavailable

Accessibility standard: Unknown

Accessibility compliance for the PDF of this book is currently unknown and may be updated in the future.

Save book to Kindle

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.

  • Array
  • Subrata Saha, Subhodip Mukherjee
  • Book: Basic Computation and Programming with C
  • Online publication: 17 July 2025
  • Chapter DOI: https://doi.org/10.1017/9781316551585.011
Available formats
×

Save book 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 Dropbox.

  • Array
  • Subrata Saha, Subhodip Mukherjee
  • Book: Basic Computation and Programming with C
  • Online publication: 17 July 2025
  • Chapter DOI: https://doi.org/10.1017/9781316551585.011
Available formats
×

Save book to Google Drive

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.

  • Array
  • Subrata Saha, Subhodip Mukherjee
  • Book: Basic Computation and Programming with C
  • Online publication: 17 July 2025
  • Chapter DOI: https://doi.org/10.1017/9781316551585.011
Available formats
×