Multiple choice

What is the output of the following program? #include<iostream.h> void main() { enum birds{parrot,crow,pigeon,sparrow}; birds b=pigeon; cout<<b; }

  1. pigeon

  2. 3

  3. 2

  4. none of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Enums assign integers starting from 0: parrot=0, crow=1, pigeon=2, sparrow=3. Since b is assigned pigeon (the third element), it has value 2. The output is the numeric value, not the name.