Monday, 18 December 2017


Ques 1) What is Array ?

Ans-->Array is a collection of elements of same type stored in continuous memory location.

Ques 2) What are the characteristics of an Array ?

Ans--> i) All the elements are of same type.
           ii) All the elements are stored in contiguous memory location.
           iii)The size should be positive integer.

Ques 3) How to declare an array ?

Ans--> <datatype>array-name[size] 

Ques 4) When to use 2D array ?

Ans-->Whenever we want to arrange any data of same type in the form of rows and columns-then we use 2D arrays.
Example: Matrix Multiplication.

Ques 5) What are the different styles of initializing a 2D array ?

Ans-->i) int a[][3]={1,2,3,4,5,6,7,8,9};
          ii) int a[][3]={{1,2,3},{4,5,6},{7,8,9}};

Ques 6) What is row major style /column major style of 2-D array arrangement ?

Ans-->In Row major style, elements of an array are arranged row after row in the memory.
        In column major style, elements of 2-D array are arrange column after column in the memory.

Ques 7) If we initialize 2-D array, why column size is compulsory ?

Ans--> Only then, compiler knows how many elements should be kept in a row.

Ques 8) What is the difference between array and string ?

Ans-->Array is a collection of elements of similar type. These similar elements could be all int, floats or chars.
                       String is collection of elements of type char, terminated by null character.

Ques 9) What is difference between Array and structure ?

Ans-->i) Array is a collection of elements of same type.
                              whereas, structure is collection of elements of different type.
          ii) Each element of array is referred by its position.
     whereas, each element of structure is referred by its unique name.

Ques 10) What is the similarity between Array and structure ?

Ans--> Both Array and structure must be defined with definite number of components.

Ques 11) Why array need to be declared before using it ?

Ans--> Array need to be declared so that compiler will know what kind of an array and how large an array we want.

Ex. int marks[30];

Here, int specifies type of variable, marks specifies the name of variable, 30 specifies how many element of type int will be in our array.

No comments:

Post a Comment

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...