An array is a collection of similar data items, that are stored under a common name. A value in an array is identified by index or subscript enclosed in square brackets with array name.
Many
applications require the processing of multiple data items that have common
characteristics. In such a situation, it is convenient to place such data items
in an Array.
An
array is a collection of similar data items, that are stored under a common
name. A value in an array is identified by index or subscript enclosed in
square brackets with array name.
The
individual data items can be integers, floating point numbers and characters
and so on, but they must be the same type and same storage class.
Each
array element is referred by specifying the array name with subscript, each
subscript enclosed in square brackets and each subscript must be a non‒negative
integer.
Thus
'n' elements array 'Q' and the elements are
Q[0], Q[1], Q2],
Q[3],..., Q[n‒1]
The
value of each subscript can be expressed as an integer constant or an integer
variable or an integer expression.
The
arrays can be used to represent not only simple list of value but also task of
data items in two, three or more dimensions.
The
C Language has the capability that enables us to define a set of similar data
items known as an array.
Suppose
you have a set of marks that you want to read into the computer, and to perform
some operations on these marks, such as rank them in ascending order, compute
their average, or find their median.
If
you think about the process of ranking a set of marks, you quickly realize that
you cannot perform such an operation until each and every grade has been
entered. Therefore, using the techniques described previously, you would read
in each marks and store it into a unique variable, perhaps with a sequence of
statements such as the following:
printf ("Enter marks1\n");
scanf("%i", &marks1);
printf ("Enter marks 2\n");
scanf ("%i", &marks2);
printf ("Enter marks 3\n");
scanf("%i", &marks3);
After
the marks have been entered, you can then proceed to rank them. This can be
done by setting up a series of if statements to compare each of the values to
determine the smallest grade, the next smallest grade, and so on, until the
maximum grade has been determined.
If
you try to write a program to perform precisely this task, you soon realize that
for any reasonably sized list of marks, the resulting program is quite large
and complex. All is not lost, however as this is one instance in which the
array comes to the rescue.
Arrays
can be classified into
•
One‒Dimensional arrays
•
Two‒Dimensional arrays
•
Multi‒Dimensional arrays
Computer Programming C: UNIT II: Arrays and Strings : Tag: Computer Science : C Programming - Arrays: Concepts and Needs
Computer Programming C
CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
English Essentials I
EN25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
தமிழர் மரபு - Heritage of Tamils
UC25H01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Calculus
MA25C01 Maths 1 M1 - 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Physics I
PH25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Applied Chemistry I
CY25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Makerspace
ME25C04 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Computer Programming C
CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Computer Programming Python
CS25C02 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation
Fundamentals of Electrical and Electronics Engineering
EE25C03 1st Semester EEE Depart | 2025 Regulation | 1st Semester 2025 Regulation
Introduction to Mechanical Engineering
ME25C03 1st Semester Mechanical Dept | 2025 Regulation | 1st Semester 2025 Regulation
Introduction to Civil Engineering
CE25C01 1st Semester Civil, Agri Departments | 2025 Regulation | 1st Semester 2025 Regulation
Essentials of Computing
CS25C03 1st Semester - AIDS, CSE, CSE(CY), IT Department | 2025 Regulation | 1st Semester 2025 Regulation
Applied Physics I Laboratory
PH25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Applied Chemistry I Laboratory
CY25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Computer Programming C Laboratory
CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Computer Programming Python Laboratory
CS25C02 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation
Engineering Drawing
ME25C01 EEE, Mech, Agri, EEE Depts | 2025 Regulation | 2nd Semester 2025 Regulation
Basic Electronics and Electrical Engineering
EE25C04 1st Semester ECE Dept | 2025 Regulation | 1st Semester 2025 Regulation
Essentials of Computing - Laboratory
CS25C03 1st Semester AIDS, CSE, CSE(CY), IT Depts | practical Laboratory Manual | 2025 Regulation | 1st Semester 2025 Regulation