1. Engineering
  2. Computer Science
  3. printing bits iteratively write a function that accepts as input...

Question: printing bits iteratively write a function that accepts as input...

Question details

Printing bits iteratively Write a function that accepts as input an unsigned char and prints the bits of the character. The function should print the bits iteratively (namely using a for loop). The function needs to print the bits that the MSB (bit 7) is printed first. Use the following statements when printing: 1. To print a O use-printf(0); 2. To print a 1 use printf(1); 3. To go the next line use printf(In); Note that you can combine the new line with any other 4. printing statement e.g., to print a 0 on the screen and skip to the next line use printf(OIn); For example if the c is A then the function output should be 01000001 Function prototype void printBitslterative(unsigned char c); Instructions: Here the function will need to iterate on all the bits. There are several ways of accomplishing it. Below is one way of doing it. Option 1: Here you will use the isBitSet() function that you coded. 1. Loop (using a for loop) on all the possible bits (bits 0-7) and check each bit whether it is set a. If the bit is set, then print a 1 otherwise print a 0

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution