while initialization of two dimensional arrays we can
initialize like a[][2] but why not a[2][] is there any
reason behind this?
Answer Posted / 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 |
Post New Answer View All Answers
What are the application of void data type in c?
main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }
#include
what is different between auto and local static? why should we use local static?
Explain bitwise shift operators?
What is actual argument?
What are the characteristics of arrays in c?
What is the difference between test design and test case design?
What is difference between union All statement and Union?
What are c identifiers?
Is void a keyword in c?
What is build process in c?
What do you mean by command line argument?
What is meant by 'bit masking'?
Explain what is page thrashing?