Discussion
For the following statement find the values generated for p and q?
int p = 0, q = 1;
p = q++;
p = ++q;
p = q--;
p = --q;
Value of p & q are
Answer: A
Correct answer: 1 1
Follow the four statements from p = 0, q = 1:
p = q++;-pgets the old 1;qbecomes 2.p = ++q;-qbecomes 3 andpgets 3.p = q--;-pgets the old 3;qbecomes 2.p = --q;-qbecomes 1 andpgets 1.
So both end at 1.
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