Discussion
If x is an array of integers, then the value of &x[i] is same as
Answer: A
Correct answer: x+i
By definition x[i] is *(x + i), so taking the address of both sides gives &x[i] == x + i. The scaling is already built into pointer arithmetic: adding 1 to an int * advances by sizeof(int) bytes. That is why the two options that multiply or add sizeof(int) explicitly are wrong - they would scale twice.
No comment is present. Be the first to comment.
Loading…
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