Discussion
If n has the value 3, then the statement a[++n] = n++;
Answer: B
Correct answer: what is assigned is compiler-dependent
The statement a[++n] = n++; both reads and modifies n twice between sequence points, and it uses the value of n on the right while also changing it on the left. The standard leaves the order unspecified, so the compiler may evaluate the subscript before or after the right-hand side. The result is undefined behaviour - what is assigned, and where, depends on the compiler.
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