Discussion
The declaration
enum cities{ bethlehem, jericho, nazareth = 1, jerusalem }
assigns the value 1 to
Answer: D
Correct answer: jericho and nazareth
Enumerators count upward from zero unless given an explicit value, and an explicit value resets the count. So bethlehem is 0, jericho is 1, nazareth is explicitly 1, and jerusalem follows at 2.
Both jericho and nazareth therefore have the value 1. C permits duplicate enumerator values, which is occasionally useful for aliases but is more often an accident - as here, where an explicit assignment collides with the automatic sequence.
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