Discussion
In C, which of the following is TRUE about arrays and pointers ?
Answer: C
The true statement is that array[i] is equivalent to *(array + i).
C defines subscripting in terms of pointer arithmetic: in an expression the array name becomes a pointer to its first element, adding i moves the pointer i elements along, and the dereference reads that element. The two forms are interchangeable by the language definition (which is also why the odd form i[array] compiles).
sizeof(array) gives the size of the whole array, for example 40 for ten 4-byte ints, not the size of a pointer; they coincide only for an array parameter, which is really a pointer. An array name is not a modifiable lvalue, so array++ is an error. Since C is true, 'None of these' is wrong.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development