What does the following program do?

```
#include
using namespace std;

bool mystery( unsigned );

int main()
{
unsigned x;

cout << "Enter an integer: ";
cin >> x;
cout << boolalpha
<< "The result is " << mystery( x ) << endl;
} // end main

// What does this function do?
bool mystery( unsigned bits )
{
const int SHIFT = 8 * sizeof( unsigned ) - 1;
const unsigned MASK = 1 << SHIFT;
unsigned total = 0;

for ( int i = 0; i < SHIFT + 1; i++, bits <<= 1 )
if ( ( bits & MASK ) == MASK )
++total;

return !( total % 2 );
} // end function mystery
```

The program prints false if the total number of 1s in the bit representation is odd,
and prints true if the number of 1s is even.

Computer Science & Information Technology

You might also like to view...

A(n) ________ is a type of attribute that will change the appearance of one specific element

Fill in the blank(s) with correct word

Computer Science & Information Technology

Forensics work requires a broad range of capabilities, many of which are typically found in conjunction with each other.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology