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

How the c program is executed?

0 Answers  


Which of these statements are false w.r.t File Functions? i)fputs() ii)fdopen() iii)fgetpos() iv)ferror() A)ii B)i,ii C)iii D)iv

6 Answers   Accenture,


What does a function declared as pascal do differently?

0 Answers  


Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

0 Answers  


What does. int *x[](); means ?

0 Answers   Wilco,


What is console in c language?

0 Answers  


How is actual parameter different from the formal parameter?

0 Answers  


What is sizeof int?

0 Answers  


What is #include stdio h and #include conio h?

0 Answers  


Write a program to print all permutations of a given string.

0 Answers   JPMorgan Chase,


how can i get the string which is having two spaces at the end.suppose the string is "Hello World ".Now at the end i have two spaces.i need to print with that spaces .

1 Answers  


What is switch in c?

0 Answers  


Categories