# Arrays

1. What is an Array?
Ans:An array is a collection of similar type of elements stored in adjacent locations

2. What is a Dimension?
Ans:
It tells us the maximum number of indexes that can be used to represent an element of an array
for 1-D ( only 1)
For 2-D ( only 2)

3. What is the difference between an array and a string?
Ans: An array is a collection of similar type of elements stored in adjacent locations.
A character array or  a string is a collection of characters terminated by a null character.

4. How to read multiple word strings?
Ans: Method 1 : scanf(“%[^\n]”, st);
Method 2 : gets( st );

5. What is the advantage of arrays?
Ans:
A set of elements can be accessed very easily using loops
Sorting of a set of elements
Generating results sheet of a set of students storing their marks & roll numbers in arrays
Processing of matrices
Processing of tabular data

6.When to use 2-D arrays?
Ans:
Whenever we need to arrange any data in the form of rows and columns – then we use 2-D arrays
Eg: Matrix multiplication
Puzzle Game
Calender generation

7. What is row major style/column major style of 2-D array arrangement?
Ans:
Row major style
Here the elements of a 2-D array are arranged row after row in the memory
Column major style
Here the elements of a 2-D array are arranged column after column in the memory

8. If we initialize a 2-D array, why column size is compulsory?
Ans:
Only then, the compiler knows how many elements should be kept in a row.

9. What are the different styles of initializing a 2-D array?
Ans:
method1:
int a[][3] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
1 2 3  4 5 6  7 8 9  10 11 12  13 14 0

method 2 :
int a[][3] = {  {1, 2 }, {4, 8, 13}, { 7, 76, 43}, {9, 17} };
1 2 0  4 8 13  7 76 43  9 17 0

10. How to declare an array?
Ans: <datatype> arrayname[size];

11. What are the characteristics of an array?
Ans: a)All the elements are of same data type.
b) All the elements will be stored in continuous memory locations.
c) The size should be a positive integer.