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.
Please log in or register to report this question.