946 views

2 Answers

Best answer
3 3 votes
C uses row-major order for arrays and indexing starts from 0 and size of a char is 1 byte. So, before a[40][10], we have 40 rows of 40 bytes = 1600 bytes plus 10 chars of 1 byte each, which occupies memory locations 0-1599, 1600-1609. So, a[40][10] strats from address 1610.
• selected by
1 1 vote

To reach a[40][10]

Skip 40 rows, and 10 columns for RMO (default in C)

=> Skip 40(size of row) elements + 10 elements.

Now, size of a row = number of total columns.

=> Skip 40(40) + 10 elements.

=> Skip 1610 elements.

 

Now, 1 element = 1B, because the element is char.

=> After 1610B is the starting address of a[40][10]



Bonus:-

Type Storage size  
char 1 byte  
unsigned char 1 byte  
signed char 1 byte  
int 2 or 4 bytes  
unsigned int 2 or 4 bytes  
short 2 bytes  
unsigned short 2 bytes  
long 8 bytes  
unsigned long 8 bytes  

Source

Answer:
Position:
Show:

Related questions

1 1 vote
2 2 answers
1.8k
1.8k views
Arjun asked Oct 10, 2016
1,841 views
Which of the following is false?Arrays are better than linked lists for sorting due to better data locality.Asymptotic time complxity for FindMax is same on an unsorted a...
4 4 votes
2 answers 2 answers
960
960 views
Arjun asked Oct 10, 2016
960 views
In a class examination marks was out of 100 and there were only 1 or 2 mark questions with total 70 questions and pass mark being 36. In order to find the most repeating ...
5 5 votes
1 answers 1 answer
2.2k
2.2k views
Arjun asked Oct 10, 2016
2,241 views
Consider a stack with 100 elements present. Suppose in a scenario, we are required to remove the first inserted element in it, which is done by POP operations followed by...
2 2 votes
2 answers 2 answers
1.4k
1.4k views
Arjun asked Oct 10, 2016
1,422 views
A function $f$ defined on stack of integer satisfies the following properties:$f(\{\}) = 1$ and$f(PUSH(S,i)) = \max (f(S),1) * i$ for all stacks $S$ and integer $i$.If a ...