Introduction
C language provides four basic data types: int, char, float, and double. These basic data types are useful but limited in handling large amounts of data. As programs grow more complex, managing data becomes challenging, leading to longer variable names for uniqueness and difficulty in focusing on correct coding.
Arrays offer a solution by allowing multiple data items to be declared and accessed with a single identifier, simplifying data management. For example, processing a list of numbers, marks, or enrollment numbers can be cumbersome with individual variables. Using arrays simplifies this process.
An array is a collection of similar data elements stored in adjacent memory locations, referred to by a single array name. In C, arrays must be declared and defined before use, specifying the array name, element type, and size. For example, to store marks of 100 students, you can define an array as int ar[100]; instead of using 100 individual variables.
Each element in an array is accessed using a subscript, and arrays allow efficient memory usage and easier data management. This unit explains the use of arrays, their types, and how to declare and initialize them with examples.
Objectives
After going through this unit you will be able to: