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 is c

4 Answers  


process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,

0 Answers   InterGraph,


Why pointers are used in c?

0 Answers  


What is modeling?

0 Answers  


Why header file is used in c?

0 Answers  






What is the meaning of && in c?

0 Answers  


String concatenation

2 Answers  


I need testPalindrome and removeSpace #include <stdio.h> #define SIZE 256 /* function prototype */ /* test if the chars in the range of [left, right] of array is a palindrome */ int testPalindrome( char array[], int left, int right ); /* remove the space in the src array and copy it over to the "copy" array */ /* set the number of chars in the "copy" array to the location that cnt points t */ void removeSpace(char src[], char copy[], int *cnt); int main( void ) { char c; /* temporarily holds keyboard input */ char string[ SIZE ]; /* original string */ char copy[ SIZE ]; /* copy of string without spaces */ int count = 0; /* length of string */ int copyCount; /* length of copy */ printf( "Enter a sentence:\n" ); /* get sentence to test from user */ while ( ( c = getchar() ) != '\n' && count < SIZE ) { string[ count++ ] = c; } /* end while */ string[ count ] = '\0'; /* terminate string */ /* make a copy of string without spaces */ removeSpace(string, copy, &copyCount); /* print whether or not the sentence is a palindrome */ if ( testPalindrome( copy, 0, copyCount - 1 ) ) { printf( "\"%s\" is a palindrome\n", string ); } /* end if */ else { printf( "\"%s\" is not a palindrome\n", string ); } /* end else */ return 0; /* indicate successful termination */ } /* end main */ void removeSpace(char src[], char copy[], int *cnt) { } int testPalindrome( char array[], int left, int right ) { }

0 Answers  


how i m write c program 1.check prime number 2.prime number series

1 Answers  


Tell me what is the purpose of 'register' keyword in c language?

0 Answers  


how to make program without <> in library.

1 Answers   ADITI,


What are the advantages of c language?

0 Answers  


Categories