I am doing a homework assignment for CSI 330 and not sure how to begin this program. It is asking me to initialize and unsigned int variable mask, with a value whose binary representation has a 1 followed by all 0's.
The second part says...
For a counter running from 1 through the number of bits do the following...
a. if bitwise-and (&) if the given integer and mask is nonzero Display 'I'
else
display 'O'
Shift the bits in mask one position to the right (using >>)
This is what I have so far but its just pretty much a guess...
#include <iostream>
#include <limits>
using namespace std;
//Function prototype
int printBinary();
int main ()
{
printBinary();
return 0;
}
int printBinary ()
{
for(int mask = numeric_limits <unsigned int>::digits() - 1; mask >= 0; --mask)
}