while initialization of two dimensional arrays we can
initialize like a[][2] but why not a[2][] is there any
reason behind this?

Answers were Sorted based on User's Feedback



while initialization of two dimensional arrays we can initialize like a[][2] but why not a[2][] is..

Answer / prady

2 dimension array a[row][col]; in this 'col' indicates size
of block,and 'row' indicates no. of blocks.
Compiler prefer memory unit size first rather no.of memory
units.

Is This Answer Correct ?    25 Yes 1 No

while initialization of two dimensional arrays we can initialize like a[][2] but why not a[2][] is..

Answer / vignesh1988i

the main reason behind this is that, if we specify the
columns instead of rows we can easily find out the number of
rows in the matrix...... but if we give just row number we
cant predict the number of columns...... that's why !!!!!!


thnak u

Is This Answer Correct ?    4 Yes 2 No

while initialization of two dimensional arrays we can initialize like a[][2] but why not a[2][] is..

Answer / kathir

Lets assume an arry arr[][3] = {..};
if you want to refer arr[1][2] then the reference to the
element will be identified using the following formula,
arr[1*NoOfColoumns(=3) + 2](you can consider it as a single
dimension array storing values in sequence).
Hence to get the address of any element in the array you
only require column info NOT rows.Thats why compiler does
not bother about no of rows!

Is This Answer Correct ?    1 Yes 0 No

while initialization of two dimensional arrays we can initialize like a[][2] but why not a[2][] is..

Answer / subhrajeet sairam mohanty

2 dimension array a[row][col]; in this 'col' indicates size
of block,and 'row' indicates no. of blocks.
Compiler prefer memory unit size first rather no.of memory
units.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What are the 4 types of functions?

0 Answers  


Can I initialize unions?

0 Answers  


write a c programme for add of two numbers with out use of arthematic operators

2 Answers  


sum of two integers values only other then integer it should print invalid input.

1 Answers  


enum day = { jan = 1 ,feb=4, april, may} what is the value of may? a)4 b)5 c)6 d)11 e)none of the above

8 Answers   HCL, Wipro,






write a program to create a sparse matrix using dynamic memory allocation.

0 Answers  


Why is c platform dependent?

0 Answers  


How do you determine a file’s attributes?

0 Answers  


write a program to search for an element in a given array. If the array was found then display its position otherwise display appropriate message in c language

18 Answers   IT Park, TCS,


What are the advantages of using new operator as compared to the function malloc ()?

0 Answers   NIIT,


Why isnt there a numbered, multi-level break statement to break out

0 Answers  


Why flag is used in c?

0 Answers  


Categories