Help
Advanced Member level 2
Hai..
Anyone help me to explain this program......
------------------------------------------------------------------------------
#include <stdio.h>
void Display_Byte(const unsigned char);
/*----------------------------------------------------*/
int main()
{
unsigned int y = 0x0a0b;
printf("%-35s","Display MS byte of unsigned int y");
Display_Byte((unsigned char)(y>>8 ));
printf("%-35s","Display LS byte of unsigned int y");
Display_Byte((unsigned char)(y & 0xff));
return 0;
}
void Display_Byte(const unsigned char CH)
{
unsigned char i, c = CH;
unsigned char Mask = 1<<7;
for(i=1; i<=8; i++)
{
putchar(c & Mask ? '1' : '0');
c<<=1;
}
putchar('\n');
}
/* OUTPUT...
Display MS byte of unsigned int y 00001010
Display LS byte of unsigned int y 00001011
*/
------------------------------------------------------------------------
Thanks.........
Anyone help me to explain this program......
------------------------------------------------------------------------------
#include <stdio.h>
void Display_Byte(const unsigned char);
/*----------------------------------------------------*/
int main()
{
unsigned int y = 0x0a0b;
printf("%-35s","Display MS byte of unsigned int y");
Display_Byte((unsigned char)(y>>8 ));
printf("%-35s","Display LS byte of unsigned int y");
Display_Byte((unsigned char)(y & 0xff));
return 0;
}
void Display_Byte(const unsigned char CH)
{
unsigned char i, c = CH;
unsigned char Mask = 1<<7;
for(i=1; i<=8; i++)
{
putchar(c & Mask ? '1' : '0');
c<<=1;
}
putchar('\n');
}
/* OUTPUT...
Display MS byte of unsigned int y 00001010
Display LS byte of unsigned int y 00001011
*/
------------------------------------------------------------------------
Thanks.........