What
is Concept of array in C
One way to think of an array is a variable that has space
for more than one piece of data or information.Arrays are something that you will find in most
programming languages, and allow programmers to store information in a variable
that has multiple slots of the information.
Depending on the language that you're using an array in,
the data type of the information may have to be the same, such as with C, Java,
C++, where an array can be defined as having an "int" datatype, for
example, and must contain whole numbers.
However, in languages like PHP or JavaScript, an array
may be able to hold more than one type of data, such as "int",
"double", Strings, etc.
In C, you can declare an array by specifying the data
type that you would like the array to have, which will determine what kind of
information it can hold, followed by the name of the array, and how many
"slots" you would like it to have for data.
For example, if we wanted to declare an array that can
hold 5 integers, called int type Array, we can do so like the example below:
int array[5];
It's just a bunch of variables in a chain. The array's
label is actually the physical address in memory. , and you try to access the
array, it will add the number in the brackets to the physical location.
Types
of Array In C:
There are two type of array in C language
1. One-dimensional
arrays
2. Multidimensional
arrays
One-dimensional arrays:
The rule of declaration of one-dimensional array
data_type array_name[array_size];
For example:
int age[5];
One disarray with value assign….
int age[5]={12,20,9,40,55};
Another way
age[0]=10;
age[1]=20;
age[2]=30;
age[3]=40;
age[4]=50;
Two dimensional array:
Multidimensional Array:
int a[3][4] = {
{ 0, 1, 2, 3} , /*
initializers for row indexed by 0 */
{4, 5, 6, 7}
, /*
initializers for row indexed by 1 */
{8, 9, 10, 11}
/* initializers for row indexed
by 2 */
};




No comments:
Post a Comment