C Programming MCQ

1:

If x is an array of interger, then the value of &x[i] is same as

A.

&x[i-1] + sizeof (int)

B.

x + sizeof (int) * i

C.

x+i

D.

none of these

 

Answer : A

Explanation :

X+i means increment in value of X not in  address of X  so it cant represent address of X. 

 &x[i] means address of the ith element. 

So & X[i-1]  defines address of i-1 element .sizeof(int) defines size of an element
So &x[i-1] + sizeof(int) means address of i-1 element plus size of an element that means address of ith element.
It cant be option c as x+i is not representing any address.

X+i means increment in value of X not in  address of X  so it cant represent address of X.
So option (A) is correct

kavitha said: (1:07pm on Monday 25th March 2013)
why it is C rather than A
Mayank said: (10:23pm on Monday 6th May 2013)
say base=1000 and i=4;
paddhu said: (2:19am on Saturday 24th August 2013)
it's C optiong
Narendra Kumar Rout said: (11:05pm on Tuesday 31st December 2013)
I think option B is also correct.

Write your comments here:


Report Error
 

Option: A

Explanation : Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here.