WAP to print a list having numbers less than 10
Answers
Answer:
This information may help you
Explanation:
How to declare an array
datatype array_name [ array_size ] ;
For example, take an array of integers 'n'.
int n[6];
n[ ] is used to denote an array 'n'. It means that 'n' is an array.
So, int n[6] means that 'n' is an array of 6 integers. Here, 6 is the size of the array i.e. there are 6 elements in the array 'n'.
array of integers in C
We need to give the size of the array because the complier needs to allocate space in the memory which is not possible without knowing the size. Compiler determines the size required for an array with the help of the number of elements of an array and the size of the data type present in the array.
Here 'int n[6]' will allocate space to 6 integers.
We can also declare an array by another method.
int n[ ] = {2, 3, 15, 8, 48, 13};
In this case, we are declaring and assigning values to the array at the same time. Here, there is no need to specify the array size because compiler gets it from { 2,3,15,8,48,13 }.
Index of an Array
Every element of an array has its index. We access any element of an array using its index.
Pictorial view of the above mentioned array is:
element 2 3 15 8 48 13
index 0 1 2 3 4 5
0, 1, 2, 3, 4 and 5 are indices. It is like they are identity of 6 different elements of an array. Index always starts from 0. So, the first element of an array has a index of 0.