Arrays and
Structures
The
variables are used to store data. These variables are the one of the basic
building blocks in C++. A single variable is used to store a single value that
can be used anywhere in the memory. In some situations, we need to store
multiple values of the same type. In that case, it needs multiple variables of
the same data type. All the values are stored randomly anywhere in the memory.
For
example, to store the roll numbers of the 100 students, it needs 100 variables
named as roll1, roll2, roll3,…….roll100 . It becomes very difficult to declare
100 variables and store all the roll numbers. In C++, the concept of Array
helps to store multiple values in a single variable. Literally, the meaning of Array is “More than one”. In other words,
array is an easy way of storing
multiple values of the same type referenced by a common name”. An array is also
a derived data type in C++.
“An array is a collection of
variables of the same type that are referenced by a common name”. In an array, the values are stored
in a fixed number of elements of the same
type sequentially in memory. Therefore, an integer array holds a sequence of
integers; a character array holds a sequence of characters, and so on. The size
of the array is referred to as its dimension.
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.