Discussion
What is the output of this C code?
void main()
{
int x = 4, y, z;
y = --x;
z = x--;
printf("%d%d%d", x, y, z);
}
Answer: B
Correct answer: 2 3 3
Follow the two statements:
y = --x;- pre-decrement, soxbecomes 3 andytakes that new value, 3.z = x--;- post-decrement, soztakes the old value 3 andxthen becomes 2.
Printing x, y, z gives 2 3 3.
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