Arrays in C Programming Language

Notes:

Arrays in C Programming Language:

Why do we need arrays?
Assume if you want to store and process n different integer values, then without arrays you may need to create n different integer variables with n different names; whereas an integer array allows us to store and process n different integer values just by creating a single variable.

Note: Arrays allow us to group of similar type of data elements under a single variable name

What is an array?
- An array is a group of homogeneous data elements i.e. list of similar type of data elements

Note:
- Arrays follow 0 based indexing

- Each element in an array is going to have an index or a subscript, hence sometimes arrays are also called as indexed variables or subscripted variables.

Example Code:

/*
int num1 = 10;
int num2 = 20;
int num3 = 30;
int num4 = 40;
int num5 = 50;

printf("%d\n",num1);
printf("%d\n",num2);
printf("%d\n",num3);
printf("%d\n",num4);
printf("%d\n",num5);
*/

int numbers[5] = {10,20,30,40,50};
int i=0;

for(i=0; i<5;i++)
{
printf("%d\n",numbers[i]);
}