Sams Teach Yourself C in 21 Days

(singke) #1
Working with Memory 591

20


6.BUG BUSTER:Is the following structure allowed?
struct quiz_answers
{
char student_name[15];
unsigned answer1 : 1;
unsigned answer2 : 1;
unsigned answer3 : 1;
unsigned answer4 : 1;
unsigned answer5 : 1;
}
Answers are not provided for the following exercises:


  1. Write a program that uses each of the bitwise logical operators. The program
    should apply the bitwise operator to a number and then reapply it to the result. You
    should observe the output to be sure you understand what’s going on.

  2. Write a program that displays the binary value of a number. For instance, if the
    user enters 3 , the program should display 00000011. (Hint: You will need to use the
    bitwise operators.)


32 448201x-CH20 8/13/02 11:16 AM Page 591

Free download pdf