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

Where in memory are my variables stored?

0 Answers  


What is putchar() function?

0 Answers  


C,c++, Java is all are structural oriented or procedure oriented language..?

6 Answers  


#include<stdio.h> #include<conio.h> # define swap(a,b) temp=a; a=b; b=temp; void main( ) { int i, j, temp; i=5; j=10; temp=0; if( i > j) swap( i, j ); printf( "%d %d %d", i, j, temp); }

9 Answers   Burning Glass,


Explain threaded binary trees?

0 Answers  






Write a program that his output * *** *****

1 Answers  


Explain how do you determine whether to use a stream function or a low-level function?

0 Answers  


While(1) { } when this loop get terminate is it a infinite loop?

5 Answers  


what is the difference between strcpy() and memcpy() function?

2 Answers  


Explain how can you tell whether a program was compiled using c versus c++?

0 Answers  


Is printf a keyword?

0 Answers  


Write a program to compute the following 1!+2!+...n!

4 Answers  


Categories