TCS
Company
The base address of a 2-D integer array NUMS of dimension 5*7 is 3000.
What will be the address of element NUMS[3][6], if array indices start from 0 and each integer takes two bytes.
a) 3056 b) 3038 c) 3054 d) 3036
Read Solution (Total 5)
-
- you can follow formula's directly but for ease i write it here manual working
as indices starts from 0 so nums[3][6] means you have to access 7th element of 4th row (as i mentioned index starts from 0 ). so before access this element we have to compute 3 rows and 6 elements of 4th row hence
(3 rows * elements in row * size)+( 6 elements * size) so that
(3*7*2)+(6*2)=54 so
address of NUMS[3][6]=base+54 = 3054
answer is c)3054 - 12 years agoHelpfull: Yes(19) No(0)
- sorry for the previous solution
formula is --------base address+word*(n*(i-1)+(j-1) if starting address is (1,1)but if starting address is (0,0)no need to subtract 1 from i and j
if starting address is (0,0) then formula is base address+word*(n*i+j)
here m=5,n=7,i=3,j=6,word of 2 bytes
so answer is 3000+2*(7*(3)+(6))
3000+2*27
3054
am i right...........?........:) - 12 years agoHelpfull: Yes(5) No(0)
- ans:3054
array starts from Nums[0][0]=3000;
given arrar address is Nums[3][6]=Nums[3+1][4+1]=Address =28-1=27
so ans is 3000+27*2=3054
- 12 years agoHelpfull: Yes(2) No(2)
- base address+word*(n*(i-1)+(j-1)
here m=5,n=7,i=3,j=6,word of 2 bytes
so answer is 3000+2*(7*(3-1)+(6-1))
3000+2*19
3038
am i right...........?........:) - 12 years agoHelpfull: Yes(1) No(9)
- Guys i need ur help...The problem is that i do not know from where should i prepare for TCS...I have gone thru open Sesame and i know the pattern..But prob ye hai ki previous year kaha se krun based upon the latest pattern..Help me pls...
- 12 years agoHelpfull: Yes(1) No(0)
TCS Other Question