Deitel & Deitel, C How to Program 6th Edition, Exercise 10.18 (Portable displayBits Function)

// 10.18 (Portable displayBits Function)

void displayBits(int num) {
int i, mask = 1, intSize;
intSize = sizeof(int) * 8;
mask <<= intSize - 1;
for (i = 1; i <= intSize; i++) {
printf("%d", mask & num ? 1 : 0);
i % 8 ? 0 : printf(" ");
num <<= 1;
}
printf("\n");
}


Let me know in the comments if this page helped you somehow.

It is nice to know if my work helped someone, thanks :)

Comments

Popular posts from this blog

Deitel & Deitel, C How to Program 6th Edition, Exercise 6.23 (Turtle Graphics)

Deitel & Deitel, C How to Program 6th Edition, Exercise 6.22 (Total Sales)

Deitel & Deitel, C How to Program 6th Edition, Exercise 5.47 (Craps Game Modification)