home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sams Teach Yourself C in 21 Days (6th Edition)
/
STYC216E.ISO
/
mac
/
Examples
/
Day20
/
shiftit.c
< prev
next >
Wrap
C/C++ Source or Header
|
2002-08-11
|
543b
|
27 lines
/* Demonstrating the shift operators. */
#include <stdio.h>
int main( void )
{
unsigned int y, x = 255;
int count;
printf("Decimal\t\tshift left by\tresult\n");
for (count = 1; count < 8; count++)
{
y = x << count;
printf("%d\t\t%d\t\t%d\n", x, count, y);
}
printf("\n\nDecimal\t\tshift right by\tresult\n");
for (count = 1; count < 8; count++)
{
y = x >> count;
printf("%d\t\t%d\t\t%d\n", x, count, y);
}
return 0;
}