Question discussion

Let x be an array. Which of the following operations are illegal?I.

279436Medium 1 reply 890 views
34
Let x be an array. Which of the following operations are illegal?I.
  • AI and II
  • BI, II and III
  • CII and III
  • DI, III and IV
  • EIII and IV
Correct answer: D

Discussion 1

0
CCommunity
I, III and IV

int x[10]; * x will store the base address of array. *
Statement I, III and IV is invalid.

Statement I and III : ++x and x++ are throwing en error while compile (lvalue required as increment operand )
Since, x is storing in the address of the array which is static value which cannot be change by the operand.

Statement IV : x*2 is also throw an error while compile (invalid operands to binary * (have 'int *' and 'int') )

Statement II : x+1 is throw a warning: assignment makes integer from pointer without a cast [enabled by default]