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 we can insert comments in a c program?

0 Answers  


Explain what is the difference between far and near ?

0 Answers  


the factorial of non-negative integer n is written n! and is defined as follows: n!=n*(n-1)*(n-2)........1(for values of n greater than or equal to 1 and n!=1(for n=0) Perform the following 1.write a c program that reads a non-negative integer and computes and prints its factorial. 2. write a C program that estimates the value of the mathematical constant e by using the formula: e=1+1/!+1/2!+1/3!+.... 3. write a c program the computes the value ex by using the formula ex=1+x/1!+xsquare/2!+xcube/3!+....

2 Answers   Ignou,


Explain why c is faster than c++?

0 Answers  


How can a process change an environment variable in its caller?

0 Answers  






Add 2 64 bit numbers on a 32 bit machine

3 Answers   EMC, Hyderabad Central University, NetApp,


what is an array

5 Answers  


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

0 Answers  


what is difference between c and c++

4 Answers  


Write a function expand(s1,s2) that expands shorthand notations like a-z in the string s1 into the equivalent complete list abc...xyz in s2 . Allow for letters of either case and digits, and be prepared to handle cases like a-b-c and a-z0-9 and -a-z. z-a:zyx......ba -1-6-:-123456- 1-9-1:123456789987654321 a-R-L:a-R...L a-b-c:abbc

0 Answers  


Is c weakly typed?

0 Answers  


who is first prime minister in india??

8 Answers   Wipro,


Categories