Simple training demonstration to show the use of bit wise And
Fork of UnionExample by
main.cpp
- Committer:
- jf1452
- Date:
- 2013-11-26
- Revision:
- 9:0add51bbe65d
- Parent:
- 8:c0d351fc572f
File content as of revision 9:0add51bbe65d:
/******************************************************************************* * This program demonstrates determines if a number is odd or even * * * * Jon Fuge * * V1.0 26/11/2013 First issue of code * *******************************************************************************/ #include "mbed.h" #include "USBSerial.h" USBSerial serial; //Virtual serial port over USB. Use Teraterm as the interface int main() { char cMyNumber = 53; // Set it to an odd number wait (10); // Wait 10 seconds to connect port if ((cMyNumber & 0x01) == 1) serial.printf("%i is odd\n\r", cMyNumber); else serial.printf("%i is even\n\r", cMyNumber); for(;;) {} // Loop forever }