6,526 views
3 votes
3 votes
Let x be an array . which of the following operations are illegal and why

a) ++x   b) x+1  c) x++  d) x - -

1 Answer

Best answer
4 votes
4 votes
Array is a const pointer. i.e., int x[] is same as const * int x

Now, ++x, incrementing a constant not allowed. Same for x++ and x--.

x + 1 =  is valid and goes to the address given by (x + 1*sizeof(*x)) in integer terms.
selected by

Related questions

2 votes
2 votes
2 answers
1
Sanjay Sharma asked Feb 18, 2017
2,636 views
let x be an array of integer . which of the following can not be present in the left hand side of an assignment statementa)x b) x+i c) * (x+i) d) &x[i]
6 votes
6 votes
2 answers
2
radha gogia asked Jul 15, 2015
9,038 views
Assume that a CPU can process $10^8$ operations per second. Suppose you have to sort an array with $10^6$ elements. Which of the following is true? 1. Insertion sort will...