Enum
Bitwise Operations
100

T/F:

An enum is a user-defined data type for integer constants.

True

100

Name one Bitwise Operation...

AND, OR, XOR, NOT

200

The default starting value for enum is...

0

**enums start at zero, much like how indexing with arrays works

200

The symbol '&' is used in what Bitwise operation?

AND

300

T/F: You can NOT assign two elements to have the same enumeration value.

enum day {sunday = 1, monday = 1, tuesday = 2,

          wednesday = 3, thursday = 4, friday = 5, saturday = 6};

False

**This is totally fine and both elements will represent the same value

300

The symbol '|' is used in what Bitwise operator?

OR

400

T/F:

Enums can be declared in both the global and local scope.

True

400

The symbol '^' is used in what Bitwise operation?

XOR

500

What will print when this code runs?:

enum year{Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec};

int main(){ int i;

   for (i=Jan; i<=Apr; i++)      

      printf("%d ", i+1);  

   return 0; }

1 2 3 4

500

What is the output of the following code?

int main()

{

// 5 in binary = 00000101 

// 9 in binary = 00001001

unsigned char a = 5, b = 9;

printf("a|b = %d\n", a | b);

return(0);

}

a|b = 13

** 00000101 | 00001001 = 00001101 (13)