By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 946 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

arrays-2d

P: 1
I wanna ask answer to this question

a 2d array is declared asA[9,7] AND each element requires 2 bytes. If A[1,1] is stored in 3000 find the memory of A[8,5].

please answer this question as soon as possible.....
Sep 17 '06 #1
Share this Question
Share on Google+
5 Replies


P: 11
I wanna ask answer to this question

a 2d array is declared asA[9,7] AND each element requires 2 bytes. If A[1,1] is stored in 3000 find the memory of A[8,5].

please answer this question as soon as possible.....



int occupies two bytes in c so here in ur query if a[1][1] is stored in then a[1][2] occupies 3002 a[1][2] is stored in 3004 like this u can go on calculating n u will get the answer
Sep 17 '06 #2

Banfa
Expert Mod 5K+
P: 8,916
int occupies two bytes in c
This is factually incorrect, on some platforms an int is 2 bytes many platforms today int is 4 bytes.

On many platforms today short is 2 bytes but c does not guarantee that all c guarantees about variable size is that

sizeof(char) == 1

sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)
Sep 17 '06 #3

P: 2
This is factually incorrect, on some platforms an int is 2 bytes many platforms today int is 4 bytes.

On many platforms today short is 2 bytes but c does not guarantee that all c guarantees about variable size is that

sizeof(char) == 1

sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)

It only depends on machine's nature either it is 16bit, 32 bit or 64bit etc. ok.
Sep 21 '06 #4

P: 2
I wanna ask answer to this question

a 2d array is declared asA[9,7] AND each element requires 2 bytes. If A[1,1] is stored in 3000 find the memory of A[8,5].

please answer this question as soon as possible.....

It only depends on machine's nature either it is 16bit, 32 bit or 64bit etc. ok.
Sep 21 '06 #5

Banfa
Expert Mod 5K+
P: 8,916
It only depends on machine's nature either it is 16bit, 32 bit or 64bit etc. ok.
It does depend on the machines nature but it is not limited to those values you give.

As far as the C standard is concerned an int can be on any byte size from 1 - infinity and the number of bits in a byte can be any number from 1 - infinity.
Sep 21 '06 #6

Post your reply

Sign in to post your reply or Sign up for a free account.