in general the output for the first set of printf statements can be obtained as array[0]aaabbb, where aaa and bbb are the integers with difference between them as 4. In general, the syntax "array[x,y]" refer to the address of the elements which are the very first elements of the first two rows present in the same column, irrespective of the values of x and y. Since the given array is a matrix of 3 rows and 2 columns, the syntax "array[x,y]" refer to the address of first elements of the first two rows i.e, they refer to the address of the elements at array[0][0] and array[1][0]. Since the array is declared as an Integer type array each element in it will occupy a space of 2 bytes. As the difference between the address of array[0][0] and array[1][0] is 4 we get a difference as 4.... Hence the output.
array[0]aaabbb array[1]aaabbb array[2]aaabbb
with difference between the integers aaa and bbb as 2*2=4.
Sir,
ReplyDeleteIts output would be:
array[0]01 /*for 1st set of printf statements
array[1]1011 /*for 2nd set printf statements
array[2]2021 /*for 3rd set printf statements
Sir,
ReplyDeletein the printf statements it should be array[0][0] instead of array[0,0]
then the output would be
array[0]01
array[1]1011
array[2]2021
but if the code " array[0,0] " is correct in the given printf statements then the out may differ....
Bharat,
ReplyDeleteRelook into the code just as a compiler does :)
looking forward for a change of opinion.
Good try...
Yes sir,
ReplyDeleteIts output is
array[0]900904
array[1]900904
array[2]900904
I think the values 900 and 904 are the positions or the co-ordinates which mainly depend upon the dimension of the array[3][2].
(Here 900+2*2=904)
Sir,
ReplyDeletethe output is:
array[0]888892
array[1]888892
array[2]888892
in general the output for the first set of printf statements can be obtained as array[0]aaabbb, where aaa and bbb are the integers with difference between them as 4.
In general,
the syntax "array[x,y]" refer to the address of the elements which are the very first elements of the first two rows present in the same column, irrespective of the values of x and y.
Since the given array is a matrix of 3 rows and 2 columns, the syntax "array[x,y]" refer to the address of first elements of the first two rows i.e, they refer to the address of the elements at array[0][0] and array[1][0].
Since the array is declared as an Integer type array each element in it will occupy a space of 2 bytes. As the difference between the address of array[0][0] and array[1][0] is 4 we get a difference as 4.... Hence the output.
array[0]aaabbb
array[1]aaabbb
array[2]aaabbb
with difference between the integers aaa and bbb as 2*2=4.