home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / lib / r_la4_01 / shiftest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-12-23  |  579 b   |  20 lines

  1. /* SHIFTEST.C - From page 340 of "Microsoft C Programming for   */
  2. /* the IBM" by Robert Lafore. This program demonstrates the     */
  3. /* bitwise right shift operator.                                */
  4. /****************************************************************/
  5.  
  6. #define TRUE 1
  7.  
  8. main()
  9. {
  10. unsigned char x1, x2;
  11.  
  12.    while(TRUE) {
  13.       printf("\n\nEnter hex number (ff or less) and number of bits ");
  14.       printf("\nto shift (8 or less; example 'cc 3'): ");
  15.       scanf("%x %d", &x1, &x2);
  16.       printf("\n%02x >> %d = %02x\n", x1, x2, x1 >> x2);
  17.    }
  18. }
  19.  
  20.